课后作业
连接openGauss
su - omm
gsql -r
1.创建分区表
1.1创建一个含有5个分区的范围分区表store
#创建分区表
create table store
(
c1 int,
c2 CHAR(5)
)
#设定范围
partition by range (c1)
(
partition store_s1 values less than (50),
partition store_s2 values less than (100),
partition store_s3 values less than (150),
partition store_s4 values less than (200),
partition store_s5 values less than (250)
);1.2在每个分区中插入记录
insert into store values (1, 'a'), (5, 'b'), (10, 'c'),(20, 'd'),(50, 'e');注:小于50的数都会插入到store_s1中!!!
注:超出范围的数据会报错!!!
insert into store values (260, 'h');
1.3 查看分区表信息
\d+ store;

2.查看分区数据
2.1查看分区1上的数据
select * from store partition(store_s1);

3.重命名分区
3.1重命名分区2
alter table store rename partition store_s2 to store_s2_2;4.删除分区
4.1删除分区5
alter table store drop partition store_s5;
4.2查看分区表信息
\d+ store;
5.增加分区
5.1增加分区6
alter table store add partition store_s6 values less than (500);
insert into store values (256, 'k');
5.2查看分区表信息
\d+ store;
6.在系统表pg_partition中查看分区信息
select * from pg_partition;

7.删除分区表
drop table store;「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




