053-017

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
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

參考:
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')));

insert into inv_history values(1, to_date(20041230,'yyyymmdd'), 1000 );
insert into inv_history values(2, to_date(20051230,'yyyymmdd'), 2000 );
insert into inv_history values(3, to_date(20060201,'yyyymmdd'), 3000 );
insert into inv_history values(4, to_date(20060301,'yyyymmdd'), 4000 );
commit;
通過以上語句執行,總共有4個分區: P0,P1,SYS_P41,SYS_P42.
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; --提示指定分區不存在
ALTER TABLE inv_history MERGE PARTITIONS
FOR(TO_DATE('20060201','yyyymmdd')), FOR(TO_DATE('2006301','yyyymmdd')) INTO PARTITION sys_py;
這樣可將SYS_P41,SYS_P42合併爲sys_py,其中for中的值一定要是分區值,否則無法合併,會提示指定分區不存在.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章