创建分区表

Posted testzcy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建分区表相关的知识,希望对你有一定的参考价值。


DROP TABLE IF EXISTS "CNYB"."CT_DAY_PLANT_001";
CREATE TABLE "CNYB"."CT_DAY_PLANT_001"(
"ID" VARCHAR(32) NOT NULL,
"YEAR" VARCHAR(4) NOT NULL,
"DATE" VARCHAR(2) NOT NULL,
"ORG_ID" VARCHAR(18) NOT NULL,
"TYPE" INTEGER NOT NULL,
"CTIME" VARCHAR(19),
"V01" DECIMAL(16,4),
"V02" DECIMAL(16,4),
"V03" DECIMAL(16,4),
CONSTRAINT "CT_DAY_PLANT_001_pkey" PRIMARY KEY ("YEAR","DATE", "ORG_ID", "ID", "TYPE")
)PARTITION BY RANGE ("YEAR");


CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2019" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2019‘) TO (‘2020‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2020" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2020‘) TO (‘2021‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2021" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2021‘) TO (‘2022‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2022" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2022‘) TO (‘2023‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2023" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2023‘) TO (‘2024‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2024" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2024‘) TO (‘2025‘)
;
CREATE TABLE "CNYB"."CT_DAY_PLANT_001_2025" PARTITION OF "CNYB"."CT_DAY_PLANT_001"
FOR VALUES FROM (‘2025‘) TO (‘2026‘)
;

以上是关于创建分区表的主要内容,如果未能解决你的问题,请参考以下文章

Hive 创建外部分区表

Oracle创建分区表操作

创建分区表(按照年份分区,自动新增分区)

Linux中如何创建新分区啊?

PostgreSQl的分区表创建,插入数据,查询

IMPALA:基于未分区表创建新的分区表