温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle与PostgreSQL拆分分区有什么不同

发布时间:2021-11-08 17:04:55 阅读:182 作者:iii 栏目:关系型数据库
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇内容主要讲解“Oracle与PostgreSQL拆分分区有什么不同”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Oracle与PostgreSQL拆分分区有什么不同”吧!

直至12版本,PostgreSQL仍没有提供直接拆分分区的功能,暂时只能通过detach&attach实现,相对于Oracle的split支持,PG显得比较的simple&naive.

PG 12

[pg12@localhost ~]$ psql -d testdb
Timing is on.
Expanded display is used automatically.
psql (12beta1)
Type "help" for help.
[local]:5432 pg12@testdb=drop table t_p1;
) to (200);
create table t_p1_maxvalue partition of t_p1 for values from (200to (maxvalue);
truncate table t_p1;
insert into t_p1(id,c1) values(1,1);
insert into t_p1(id,c1) values(2,100);
insert into t_p1(id,c1) values(3,125);
insert into t_p1(id,c1) values(4,200);
insert into t_p1(id,c1) values(5,250);
insert into t_p1(id,c1) values(6,300);
insert into t_p1(id,c1) values(7,350);
insert into t_p1(id,c1) values(8,4500);
alter table t_p1 detach partition t_p1_maxvalue;
create table t_p1_3 partition of t_ERROR:  table "t_p1" does not exist
Time8.497 ms
[local]:5432 pg12@testdb=create table t_p1 (id int, c1 intpartition by range (c1);
p1 for values from (200to (300);
insert into t_p1_3 select * from t_p1_maxvalue where c1 >= 200 and c1 < 300;
delete from t_p1_maxvalue where c1 >= 200 and c1 < 300;
alter table t_p1 attach partition t_p1_maxvalue for values from (300to (maxvalue);CREATE TABLE
Time235.099 ms
[local]:5432 pg12@testdb=create table t_p1_default partition of t_p1 default;
CREATE TABLE
Time11.941 ms
[local]:5432 pg12@testdb=create table t_p1_1 partition of t_p1 for values from (1to (100);
CREATE TABLE
Time15.247 ms
[local]:5432 pg12@testdb=create table t_p1_2 partition of t_p1 for values from (100to (200);
CREATE TABLE
Time1.705 ms
[local]:5432 pg12@testdb=create table t_p1_maxvalue partition of t_p1 for values from (200to (maxvalue);
CREATE TABLE
Time1.842 ms
[local]:5432 pg12@testdb=# 
[local]:5432 pg12@testdb=truncate table t_p1;
TRUNCATE TABLE
Time3.413 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(1,1);
INSERT 0 1
Time1.152 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(2,100);
INSERT 0 1
Time0.871 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(3,125);
INSERT 0 1
Time0.487 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(4,200);
INSERT 0 1
Time0.949 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(5,250);
INSERT 0 1
Time0.494 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(6,300);
INSERT 0 1
Time0.463 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(7,350);
INSERT 0 1
Time0.481 ms
[local]:5432 pg12@testdb=insert into t_p1(id,c1) values(8,4500);
INSERT 0 1
Time0.464 ms
[local]:5432 pg12@testdb=# 
[local]:5432 pg12@testdb=alter table t_p1 detach partition t_p1_maxvalue;
ALTER TABLE
Time0.864 ms
[local]:5432 pg12@testdb=create table t_p1_3 partition of t_p1 for values from (200to (300);
CREATE TABLE
Time1.752 ms
[local]:5432 pg12@testdb=insert into t_p1_3 select * from t_p1_maxvalue where c1 >= 200 and c1 < 300;
INSERT 0 2
Time7.578 ms
[local]:5432 pg12@testdb=delete from t_p1_maxvalue where c1 >= 200 and c1 < 300;
DELETE 2
Time21.992 ms
[local]:5432 pg12@testdb=alter table t_p1 attach partition t_p1_maxvalue for values from (300to (maxvalue);
ALTER TABLE
Time7.356 ms
[local]:5432 pg12@testdb=#

Oracle

TEST-orcl@DESKTOP-V430TU3>create table t_p1(id int,c1 int)
  2  partition by range(c1)
  3  (partition p1 values less than(100),
  4   partition p2 values less than(200),
  5   partition pmax values less than(maxvalue)
  6  );
Table created.
TEST-orcl@DESKTOP-V430TU3>
TEST-orcl@DESKTOP-V430TU3>truncate table t_p1;
Table truncated.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(1,1);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(2,100);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(3,125);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(4,200);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(5,250);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(6,300);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(7,350);
1 row created.
TEST-orcl@DESKTOP-V430TU3>insert into t_p1(id,c1) values(8,4500);
1 row created.
TEST-orcl@DESKTOP-V430TU3>alter table t_p1 split partition pmax at(1000into (partition p3,partition pmx);
Table altered.
TEST-orcl@DESKTOP-V430TU3>

可以参照EDB的做法,加入此兼容性.

到此,相信大家对“Oracle与PostgreSQL拆分分区有什么不同”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:http://blog.itpub.net/6906/viewspace-2652554/

AI

开发者交流群×