Oracle與PostgreSQL拆分分區(qū)有什么不同-創(chuàng)新互聯(lián)

本篇內(nèi)容主要講解“Oracle與PostgreSQL拆分分區(qū)有什么不同”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Oracle與PostgreSQL拆分分區(qū)有什么不同”吧!

創(chuàng)新互聯(lián)建站公司2013年成立,先為瓊結(jié)等服務(wù)建站,瓊結(jié)等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為瓊結(jié)企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

直至12版本,PostgreSQL仍沒有提供直接拆分分區(qū)的功能,暫時只能通過detach&attach實(shí)現(xiàn),相對于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 (200) to (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
Time: 8.497 ms
[local]:5432 pg12@testdb=# create table t_p1 (id int, c1 int) partition by range (c1);
p1 for values from (200) to (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 (300) to (maxvalue);CREATE TABLE
Time: 235.099 ms
[local]:5432 pg12@testdb=# create table t_p1_default partition of t_p1 default;
CREATE TABLE
Time: 11.941 ms
[local]:5432 pg12@testdb=# create table t_p1_1 partition of t_p1 for values from (1) to (100);
CREATE TABLE
Time: 15.247 ms
[local]:5432 pg12@testdb=# create table t_p1_2 partition of t_p1 for values from (100) to (200);
CREATE TABLE
Time: 1.705 ms
[local]:5432 pg12@testdb=# create table t_p1_maxvalue partition of t_p1 for values from (200) to (maxvalue);
CREATE TABLE
Time: 1.842 ms
[local]:5432 pg12@testdb=# 
[local]:5432 pg12@testdb=# truncate table t_p1;
TRUNCATE TABLE
Time: 3.413 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(1,1);
INSERT 0 1
Time: 1.152 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(2,100);
INSERT 0 1
Time: 0.871 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(3,125);
INSERT 0 1
Time: 0.487 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(4,200);
INSERT 0 1
Time: 0.949 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(5,250);
INSERT 0 1
Time: 0.494 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(6,300);
INSERT 0 1
Time: 0.463 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(7,350);
INSERT 0 1
Time: 0.481 ms
[local]:5432 pg12@testdb=# insert into t_p1(id,c1) values(8,4500);
INSERT 0 1
Time: 0.464 ms
[local]:5432 pg12@testdb=# 
[local]:5432 pg12@testdb=# alter table t_p1 detach partition t_p1_maxvalue;
ALTER TABLE
Time: 0.864 ms
[local]:5432 pg12@testdb=# create table t_p1_3 partition of t_p1 for values from (200) to (300);
CREATE TABLE
Time: 1.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
Time: 7.578 ms
[local]:5432 pg12@testdb=# delete from t_p1_maxvalue where c1 >= 200 and c1 < 300;
DELETE 2
Time: 21.992 ms
[local]:5432 pg12@testdb=# alter table t_p1 attach partition t_p1_maxvalue for values from (300) to (maxvalue);
ALTER TABLE
Time: 7.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(1000) into (partition p3,partition pmx);
Table altered.
TEST-orcl@DESKTOP-V430TU3>

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

到此,相信大家對“Oracle與PostgreSQL拆分分區(qū)有什么不同”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

本文標(biāo)題:Oracle與PostgreSQL拆分分區(qū)有什么不同-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://muchs.cn/article26/hepjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化App開發(fā)企業(yè)建站、網(wǎng)站設(shè)計(jì)、軟件開發(fā)網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)