• 创建数据库表。
  1. CREATE TABLE test (c1 INT PRIMARY KEY, c2 VARCHAR(50)) REPLICA_NUM = 3, PRIMARY_ZONE = 'zone1';
  • 创建一个复制表。
  1. CREATE TABLE item (i_id INT
  2. , i_name VARCHAR(24)
  3. , i_price DECIMAL(5,2)
  4. , i_im_id INT
  5. , PRIMARY KEY(i_id)) COMPRESS FOR QUERY pctfree=0 BLOCK_SIZE=16384
  6. DUPLICATE_SCOPE='cluster' LOCALITY='F@zone1, F@zone2,R{all_server}@zone3' primary_zone='zone1';
  • 创建带索引的表。
  1. create table t1 (c1 int primary key, c2 int) partition by hash(c1) partitions 8;
  • 创建一级分区为 range 分区,二级分区为 hash 分区的表。
  1. partition by range(c1) subpartition by hash(c2) subpartitions 5
  2. (partition p0 values less than(0), partition p1 values less than(100));
  • 开启 encoding 并使用 zstd 压缩,宏块保留空间为 5%。
  • 创建一个事务级临时表。
  1. create global temporary table t1 (c1 int) on commit delete rows ;
  • 创建一个带约束的表。
  1. create table t1 (c1 int, c2 int, c3 int, CONSTRAINT equal_check CHECK(c2 = c3 * 2) ENABLE VALIDATE);
  • 创建非模板化的二级分区表。
  • 创建表 t1 的并行度为 3。