GBase8c 自动分区例子

GBase8c 自动分区例子

DROP TABLE IF EXISTS t_auto_create_partition;

CREATE TABLE t_auto_create_partition (
    r_id character varying(32) NOT NULL,
    s_id character varying(200),
    r_ratio character varying(100),
    create_time timestamp(0) without time zone DEFAULT LOCALTIMESTAMP NOT NULL
) PARTITION BY RANGE ("create_time") INTERVAL ('1 month') 
(
    PARTITION p1 VALUES LESS THAN('2020-01-01 00:00:00')
);

-- 插入测试数据
INSERT INTO t_auto_create_partition (r_id, s_id, r_ratio, create_time)
VALUES
    ('1', 's1', 'ratio1', '2020-01-01 10:00:00'),
    ('2', 's2', 'ratio2', '2021-02-01 10:00:00'),
	('22', 's22', 'ratio2', '2021-02-03 10:00:00'),
    ('3', 's3', 'ratio3', '2022-03-01 10:00:00'),
	('4', 's4', 'ratio4', '2023-04-01 10:00:00'),
    ('5', 's5', 'ratio5', '2024-05-01 10:00:00'),
    ('6', 's6', 'ratio6', '2025-06-01 10:00:00'),
	('7', 's7', 'ratio7', '2020-03-06 10:00:00'),
	('8', 's8', 'ratio8', '2019-07-04 10:00:00')
	;
	

select * from t_auto_create_partition partition(p1);
select * from t_auto_create_partition partition(sys_p7);
select * from pg_partition where parentid = (select parentid from pg_partition where relname = 't_auto_create_partition' and parttype = 'r');

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值