Oracle OCP 1Z0 053 Q17(Auto Partition 自動分割槽)
17.The INV_HISTORY table is created using the command:
SQL>CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt NUMBER(10,2))
partition by range (inv_date) interval
(numtoyminterval(1,'month')) (partition p0
values less than (to_date('01-01-2005','dd-mm-yyyy')), partition p1 values less than
(to_date('01-01-2006','dd-mm-yyyy')));
The following data has been inserted into the INV_HISTORY table :
INV_NO INV_DATE INV_AMT
1 30-dec-2004 1000
2 30-dec-2005 2000
3 1-feb-2006 3000
4 1-mar-2006 4000
5 1-apr-2006 5000
You would like to store the data belonging to the year 2006 in a single partition and issue the command:
SQL> ALTER TABLE inv_history MERGE PARTITIONS
FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-apr-2006')) INTO PARTITION sys_py;
What would be the outcome of this command?
A. It executes successfully, and the transition point is set to '1-apr-2006'.
B. It executes successfully, and the transition point is set to '15-apr-2006'.
C. It produces an error because the partitions specified for merging are not adjacent.
D. It produces an error because the date values specified in the merge do not match the date values
stored in the table.
Answer: C
這裡, 11g之後使用interval來實現自動擴充套件分割槽,簡化了維護。
interval (numtoyminterval(1,'month'))一個月一個分割槽.
插入資料之後,產生了新的分割槽:
![](https://i.iter01.com/images/ba42cb471e30d40da4beda66cb57988d8e087fe15cc29dbef3498f123feb6d0d.png)
實驗:
SQL> CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt NUMBER(10,2))
2 partition by range (inv_date) interval
3 (numtoyminterval(1,'month'))
4 (partition p0 values less than (to_date('01-01-2005','dd-mm-yyyy')),
5 partition p1 values less than (to_date('01-01-2006','dd-mm-yyyy')));
Table created.
SQL> insert into INV_HISTORY values(1, to_date('30-dec-2004', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(2, to_date('30-dec-2005', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(3, to_date('1-feb-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(4, to_date('30-mar-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(5, to_date('30-apr-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> commit;
Commit complete.
SQL> ALTER TABLE inv_history MERGE PARTITIONS
2 FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-apr-2006')) INTO PARTITION sys_py;
ALTER TABLE inv_history MERGE PARTITIONS
*
ERROR at line 1:
ORA-14274: partitions being merged are not adjacent
這裡說的是分割槽不相鄰,不能合併
改變合併分割槽的條件:
SQL> ALTER TABLE inv_history MERGE PARTITIONS
2 FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-mar-2006')) INTO PARTITION sys_py;
ALTER TABLE inv_history MERGE PARTITIONS
Table altered.
合併分割槽之後,分割槽調整為:
![](https://i.iter01.com/images/e75cb58caf320548f6145520859eef1d372c3b201a3c3d03603d2cfa6978ceaa.png)
從這裡看到,Oracle 11G的自動分割槽特性還算是挺只能的
SQL>CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt NUMBER(10,2))
partition by range (inv_date) interval
(numtoyminterval(1,'month')) (partition p0
values less than (to_date('01-01-2005','dd-mm-yyyy')), partition p1 values less than
(to_date('01-01-2006','dd-mm-yyyy')));
The following data has been inserted into the INV_HISTORY table :
INV_NO INV_DATE INV_AMT
1 30-dec-2004 1000
2 30-dec-2005 2000
3 1-feb-2006 3000
4 1-mar-2006 4000
5 1-apr-2006 5000
You would like to store the data belonging to the year 2006 in a single partition and issue the command:
SQL> ALTER TABLE inv_history MERGE PARTITIONS
FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-apr-2006')) INTO PARTITION sys_py;
What would be the outcome of this command?
A. It executes successfully, and the transition point is set to '1-apr-2006'.
B. It executes successfully, and the transition point is set to '15-apr-2006'.
C. It produces an error because the partitions specified for merging are not adjacent.
D. It produces an error because the date values specified in the merge do not match the date values
stored in the table.
Answer: C
這裡, 11g之後使用interval來實現自動擴充套件分割槽,簡化了維護。
interval (numtoyminterval(1,'month'))一個月一個分割槽.
![](https://i.iter01.com/images/ba42cb471e30d40da4beda66cb57988d8e087fe15cc29dbef3498f123feb6d0d.png)
實驗:
SQL> CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt NUMBER(10,2))
2 partition by range (inv_date) interval
3 (numtoyminterval(1,'month'))
4 (partition p0 values less than (to_date('01-01-2005','dd-mm-yyyy')),
5 partition p1 values less than (to_date('01-01-2006','dd-mm-yyyy')));
Table created.
SQL> insert into INV_HISTORY values(1, to_date('30-dec-2004', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(2, to_date('30-dec-2005', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(3, to_date('1-feb-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(4, to_date('30-mar-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> insert into INV_HISTORY values(5, to_date('30-apr-2006', 'dd-mon-yyyy'), 1000);
1 row created.
SQL> commit;
Commit complete.
SQL> ALTER TABLE inv_history MERGE PARTITIONS
2 FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-apr-2006')) INTO PARTITION sys_py;
ALTER TABLE inv_history MERGE PARTITIONS
*
ERROR at line 1:
ORA-14274: partitions being merged are not adjacent
這裡說的是分割槽不相鄰,不能合併
改變合併分割槽的條件:
SQL> ALTER TABLE inv_history MERGE PARTITIONS
2 FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-mar-2006')) INTO PARTITION sys_py;
ALTER TABLE inv_history MERGE PARTITIONS
Table altered.
合併分割槽之後,分割槽調整為:
![](https://i.iter01.com/images/e75cb58caf320548f6145520859eef1d372c3b201a3c3d03603d2cfa6978ceaa.png)
從這裡看到,Oracle 11G的自動分割槽特性還算是挺只能的
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8520577/viewspace-2075295/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle Partition 分割槽詳細總結Oracle
- 分割槽Partition
- Oracle查詢Interval partition分割槽表內資料Oracle
- Oracle12c:建立主分割槽、子分割槽,實現自動分割槽插入效果Oracle
- 分割槽partition知識點
- Spark學習——分割槽Partition數Spark
- 分割槽函式Partition By的基本用法函式
- Kafka分割槽分配策略(Partition Assignment Strategy)Kafka
- oracle分割槽表和分割槽表exchangeOracle
- 分割槽表之自動增加分割槽(11G)
- 分割槽函式partition by的基本用法【轉載】函式
- oracle分割槽表和非分割槽表exchangeOracle
- [oracle] expdp 匯出分割槽表的分割槽Oracle
- 讀取oracle long型別及判斷是否自動分割槽表Oracle型別
- Oracle分割槽表基礎運維-07增加分割槽(2 HASH分割槽)Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(1範圍分割槽)Oracle運維
- 使用parted建立大分割槽時 mkpart Warning: The resulting partition is not properly
- Linux磁碟分割槽及自動掛載Linux
- ORACLE分割槽表梳理系列Oracle
- oracle 分割槽表move和包含分割槽表的lob moveOracle
- Oracle分割槽表基礎運維-09刪除分割槽Oracle運維
- Oracle分割槽表基礎運維-05組合分割槽Oracle運維
- Oracle分割槽表基礎運維-02範圍分割槽Oracle運維
- Oracle分割槽表基礎運維-03HASH分割槽Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(3列表分割槽)Oracle運維
- MySQL全面瓦解29:使用Partition功能實現水平分割槽MySql
- Oracle分割槽表基礎運維-04列表分割槽Oracle運維
- 從10046看Oracle分割槽裁剪Oracle
- Hive的靜態分割槽與動態分割槽Hive
- Oracle分割槽表基礎運維-06分割槽表索引Oracle運維索引
- Linux硬碟分割槽及開機自動掛載Linux硬碟
- Oracle分割槽表基礎運維-01分割槽表分類Oracle運維
- Hive動態分割槽Hive
- oracle分割槽交換(exchange)技術Oracle
- 對oracle分割槽表的理解整理Oracle
- oracle將表配置為分割槽表Oracle
- oracle 普通表-分割槽表改造流程Oracle
- Oracle SQL調優之分割槽表OracleSQL
- Oracle分割槽表基礎運維-07增加分割槽(4 RANGE_HASH)Oracle運維