Doris中如何创建多分区表?

提问者:帅平 问题分类:大数据

Doris中如何创建多分区表?

1 个回答
娇喘界的扛把子
娇喘界的扛把子

创建多分区其实就是需要自己去根据某个字段定义分区,例如:

CREATE TABLE `user` (
  `id` int(10) COMMENT "唯一id",
  `name` varchar(20) COMMENT "",
  `idcard` varchar(18) COMMENT "身份证",
  `age` TINYINT(3) NULL COMMENT "年龄",
	`cts` DATE NOT NULL COMMENT "数据创建时间"
) 
DUPLICATE KEY(`id`, `name`,`idcard`,`age`)
PARTITION BY RANGE(`cts`)
(
    PARTITION p202201 VALUES LESS THAN ('2022-02-01'),
    PARTITION p202202 VALUES LESS THAN ('2022-03-01'),
    PARTITION p202203 VALUES LESS THAN ('2022-04-01')
)
DISTRIBUTED BY HASH(`id`) BUCKETS 10
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "V2"
)

发布于:4周前 (11-02)
我来回答