Oracle 11g 分割槽拆分與合併
時間範圍分割槽拆分
create table emp (
id number(6) not null,
hire_date date not null)
partition by range(hire_date)
(partition p_1998 values less than (to_date('1998-12-31','YYYY-MM-DD')),
partition p_1999 values less than (to_date('1999-12-31','YYYY-MM-DD')),
partition p_default values less than (maxvalue)
);
insert into emp values(10,to_date('1999-5-20','YYYY-MM-DD'));
insert into emp values(20,to_date('1999-8-10','YYYY-MM-DD'));
SQL> select count(*) from emp partition(p_1999);
COUNT(*)
----------
2
將p_1999分割槽拆分成兩個分割槽
SQL> ALTER TABLE emp SPLIT PARTITION p_1999
2 AT (to_date('1999-07-01','YYYY-MM-DD'))
3 INTO (PARTITION p_1999_01, PARTITION p_1999_02);
表已更改。
SQL> select count(*) from emp partition(p_1999_01);
COUNT(*)
----------
1
SQL> select count(*) from emp partition(p_1999_02);
COUNT(*)
----------
1
將p_default分割槽拆分成兩個分割槽
SQL> insert into emp values(30,to_date('2000-5-27','YYYY-MM-DD'));
已建立 1 行。
SQL> insert into emp values(40,to_date('2001-10-02','YYYY-MM-DD'));
已建立 1 行。
SQL> select count(*) from emp partition(p_default);
COUNT(*)
----------
2
SQL> ALTER TABLE emp SPLIT PARTITION p_default
2 AT (to_date('2000-12-31','YYYY-MM-DD'))
3 INTO (PARTITION p_2000, PARTITION p_default);
表已更改。
SQL> select count(*) from emp partition(p_default);
COUNT(*)
----------
1
SQL> select count(*) from emp partition(p_2000);
COUNT(*)
----------
1
SQL> select * from emp partition(p_default);
ID HIRE_DATE
---------- -------------------
40 2001-10-02 00:00:00
SQL> select * from emp partition(p_2000);
ID HIRE_DATE
---------- -------------------
30 2000-05-27 00:00:00
LIST分割槽拆分
SQL> create table dept (
2 id number(6) not null,
3 area varchar2(15) not null)
4 partition by list(area)
5 (
6 PARTITION asia VALUES ('CHINA', 'THAILAND'),
7 PARTITION europe VALUES ('GERMANY', 'ITALY', 'SWITZERLAND'),
8 PARTITION west VALUES ('AMERICA'),
9 PARTITION east VALUES ('INDIA'),
10 PARTITION rest VALUES (DEFAULT));
表已建立。
SQL> insert into dept values(10,'MEXICO');
已建立 1 行。
SQL> insert into dept values(20,'COLOMBIA');
已建立 1 行。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
2
SQL> ALTER TABLE dept SPLIT PARTITION rest
2 VALUES ('MEXICO', 'COLOMBIA')
3 INTO (PARTITION south, PARTITION rest);
表已更改。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
0
SQL> select count(*) from dept partition(south);
COUNT(*)
----------
2
分割槽合併
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='EMP';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
EMP P_1998
EMP P_1999_01
EMP P_1999_02
EMP P_2000
EMP P_DEFAULT
SQL> ALTER TABLE emp
2 MERGE PARTITIONS P_1999_01, P_1999_02 INTO PARTITION P_1999;
表已更改。
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='EMP';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
EMP P_1998
EMP P_1999
EMP P_2000
EMP P_DEFAULT
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='DEPT';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
DEPT ASIA
DEPT EUROPE
DEPT WEST
DEPT EAST
DEPT SOUTH
DEPT REST
已選擇6行。
SQL> ALTER TABLE dept
2 MERGE PARTITIONS south, rest INTO PARTITION rest;
表已更改。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
2
create table emp (
id number(6) not null,
hire_date date not null)
partition by range(hire_date)
(partition p_1998 values less than (to_date('1998-12-31','YYYY-MM-DD')),
partition p_1999 values less than (to_date('1999-12-31','YYYY-MM-DD')),
partition p_default values less than (maxvalue)
);
insert into emp values(10,to_date('1999-5-20','YYYY-MM-DD'));
insert into emp values(20,to_date('1999-8-10','YYYY-MM-DD'));
SQL> select count(*) from emp partition(p_1999);
COUNT(*)
----------
2
將p_1999分割槽拆分成兩個分割槽
SQL> ALTER TABLE emp SPLIT PARTITION p_1999
2 AT (to_date('1999-07-01','YYYY-MM-DD'))
3 INTO (PARTITION p_1999_01, PARTITION p_1999_02);
表已更改。
SQL> select count(*) from emp partition(p_1999_01);
COUNT(*)
----------
1
SQL> select count(*) from emp partition(p_1999_02);
COUNT(*)
----------
1
將p_default分割槽拆分成兩個分割槽
SQL> insert into emp values(30,to_date('2000-5-27','YYYY-MM-DD'));
已建立 1 行。
SQL> insert into emp values(40,to_date('2001-10-02','YYYY-MM-DD'));
已建立 1 行。
SQL> select count(*) from emp partition(p_default);
COUNT(*)
----------
2
SQL> ALTER TABLE emp SPLIT PARTITION p_default
2 AT (to_date('2000-12-31','YYYY-MM-DD'))
3 INTO (PARTITION p_2000, PARTITION p_default);
表已更改。
SQL> select count(*) from emp partition(p_default);
COUNT(*)
----------
1
SQL> select count(*) from emp partition(p_2000);
COUNT(*)
----------
1
SQL> select * from emp partition(p_default);
ID HIRE_DATE
---------- -------------------
40 2001-10-02 00:00:00
SQL> select * from emp partition(p_2000);
ID HIRE_DATE
---------- -------------------
30 2000-05-27 00:00:00
LIST分割槽拆分
SQL> create table dept (
2 id number(6) not null,
3 area varchar2(15) not null)
4 partition by list(area)
5 (
6 PARTITION asia VALUES ('CHINA', 'THAILAND'),
7 PARTITION europe VALUES ('GERMANY', 'ITALY', 'SWITZERLAND'),
8 PARTITION west VALUES ('AMERICA'),
9 PARTITION east VALUES ('INDIA'),
10 PARTITION rest VALUES (DEFAULT));
表已建立。
SQL> insert into dept values(10,'MEXICO');
已建立 1 行。
SQL> insert into dept values(20,'COLOMBIA');
已建立 1 行。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
2
SQL> ALTER TABLE dept SPLIT PARTITION rest
2 VALUES ('MEXICO', 'COLOMBIA')
3 INTO (PARTITION south, PARTITION rest);
表已更改。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
0
SQL> select count(*) from dept partition(south);
COUNT(*)
----------
2
分割槽合併
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='EMP';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
EMP P_1998
EMP P_1999_01
EMP P_1999_02
EMP P_2000
EMP P_DEFAULT
SQL> ALTER TABLE emp
2 MERGE PARTITIONS P_1999_01, P_1999_02 INTO PARTITION P_1999;
表已更改。
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='EMP';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
EMP P_1998
EMP P_1999
EMP P_2000
EMP P_DEFAULT
SQL> SELECT table_name,partition_name FROM USER_tab_partitions where table_name='DEPT';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------------
DEPT ASIA
DEPT EUROPE
DEPT WEST
DEPT EAST
DEPT SOUTH
DEPT REST
已選擇6行。
SQL> ALTER TABLE dept
2 MERGE PARTITIONS south, rest INTO PARTITION rest;
表已更改。
SQL> select count(*) from dept partition(rest);
COUNT(*)
----------
2
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2122057/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 合併分割槽(coalesce partition)
- 【實驗】【PARTITION】RANGE分割槽表合併分割槽
- win10怎麼合併分割槽_win10合併分割槽的方法Win10
- 全面學習分割槽表及分割槽索引(11)--合併表分割槽索引
- mac分割槽合併APFS容器Mac
- MapReduce(三):分割槽、排序、合併排序
- java 拆分與合併字串Java字串
- Oracle vs PostgreSQL DBA(13)- 拆分(split)分割槽OracleSQL
- MyISAM分割槽表遷移 && 合併
- oracle 11g 分割槽表Oracle
- Goldengate的拆分與合併Go
- win10u盤分割槽怎麼合併 win10如何把U分割槽合併Win10
- Win10系統怎麼合併磁碟分割槽 win10合併磁碟分割槽的方法Win10
- ORACLE 11G分割槽表新功能:列表--範圍分割槽Oracle
- 資料檔案合併與拆分
- 命令列中的拆分與合併命令列
- Oracle分割槽表基礎運維-05組合分割槽Oracle運維
- win10分割槽合併不了的解決方法_win10分割槽合併不了如何處理Win10
- [引用分割槽表]Oracle 11g新特性之引用分割槽表Oracle
- ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表Oracle
- 【ORACLE新特性】11G 分割槽新特性Oracle
- [間隔分割槽]Oracle10g、11g建立間隔分割槽表Oracle
- opencv 影像的 ROI、通道的拆分與合併OpenCV
- 【原創】ORACLE 分割槽與索引Oracle索引
- mysql表水平拆分和分割槽分表MySql
- Windows7系統硬碟合併分割槽的方法Windows硬碟
- Oracle 11g 雜湊、LIST分割槽測試Oracle
- 使用Oracle Database 11g建立Interval分割槽表OracleDatabase
- Oracle 11g的新特性分割槽:System PartitionOracle
- 建立oracle10g 11g分割槽表Oracle
- win10分割槽合併保留資料怎麼操作_win10硬碟合併分割槽並保留檔案詳細步驟Win10硬碟
- Oracle分割槽表及分割槽索引Oracle索引
- oracle 分割槽Oracle
- 請求合併與拆分在併發場景中應用
- 簡單ORACLE分割槽表、分割槽索引Oracle索引
- oracle分割槽表和分割槽表exchangeOracle
- Flink SQL FileSystem Connector 分割槽提交與自定義小檔案合併策略 SQL
- oracle組合分割槽系列二(composite hash partition)Oracle