Oracle分割槽技術-- interval parition實驗及總結
Oracle分割槽技術-- interval parition實驗及總結
SQL> create user part identified by "part" default tablespace part;
SQL> grant connect,resource to part;
INTERVAL PARTITION
partition by range(c3)
interval(numtoyminterval (1,'month'))
(partition part1 values less than (to_date('2010-01-01','YYYY-MM-DD')),
partition part2 values less than (to_date('2010-02-01','YYYY-MM-DD'))
);
TABLE_NAME PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
MONTH_PART PART1 PART
MONTH_PART PART2 PART
Session altered.
SQL> select * from MONTH_PART;
C1 C3
---------- ----------
0 2012-01-01
1 2012-02-01
2 2012-03-01
3 2012-04-01
4 2012-05-01
5 2012-06-01
6 2012-07-01
7 2012-08-01
8 2012-09-01
9 2012-10-01
10 2012-11-01
11 2012-12-01
12 rows selected.
TABLE_NAME PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
MONTH_PART PART1 PART
MONTH_PART PART2 PART
MONTH_PART SYS_P11599 PART
MONTH_PART SYS_P11600 PART
MONTH_PART SYS_P11601 PART
MONTH_PART SYS_P11602 PART
MONTH_PART SYS_P11603 PART
MONTH_PART SYS_P11604 PART
MONTH_PART SYS_P11605 PART
MONTH_PART SYS_P11606 PART
MONTH_PART SYS_P11607 PART
MONTH_PART SYS_P11608 PART
MONTH_PART SYS_P11609 PART
MONTH_PART SYS_P11610 PART
14 rows selected.
檢視單個分割槽中的資料
C1 C3
---------- ----------
7 2012-08-01
SQL> create tablespace p2 datafile '/u01/app/oradata/hou/p2.dbf' size 10M autoextend on next 10M maxsize 31G;
partition by range(c3)
interval(numtoyminterval (1,'month')) store in(p1,p2)
(partition part2010_01
values less than (to_date('2010-02-01','yyyy-mm-dd')),
partition part2010_02
values less than (to_date('2010-03-01','yyyy-mm-dd'))
);
TABLE_NAME PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
INTERVAL_PARTITION PART2010_01 PART
INTERVAL_PARTITION PART2010_02 PART
Session altered.
C1 C3
---------- ----------
0 2010-01-01
1 2010-02-01
2 2010-03-01
3 2010-04-01
4 2010-05-01
5 2010-06-01
6 2010-07-01
7 2010-08-01
8 2010-09-01
9 2010-10-01
10 2010-11-01
11 2010-12-01
12 rows selected.
SQL> select TABLE_NAME,PARTITION_NAME,TABLESPACE_NAME from user_tab_partitions where table_name='INTERVAL_PARTITION' order by PARTITION_NAME;
TABLE_NAME PARTITION_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
INTERVAL_PARTITION PART2010_01 PART
INTERVAL_PARTITION PART2010_02 PART
INTERVAL_PARTITION SYS_P11642 P1
INTERVAL_PARTITION SYS_P11643 P2
INTERVAL_PARTITION SYS_P11644 P1
INTERVAL_PARTITION SYS_P11645 P2
INTERVAL_PARTITION SYS_P11646 P1
INTERVAL_PARTITION SYS_P11647 P2
INTERVAL_PARTITION SYS_P11648 P1
INTERVAL_PARTITION SYS_P11649 P2
INTERVAL_PARTITION SYS_P11650 P1
INTERVAL_PARTITION SYS_P11651 P2
12 rows selected.
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ ---------------
INTERVAL_PARTITION PART2010_01 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1 PART
INTERVAL_PARTITION PART2010_02 TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2 PART
INTERVAL_PARTITION SYS_P11642 TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 3 P1
INTERVAL_PARTITION SYS_P11643 TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 4 P2
INTERVAL_PARTITION SYS_P11644 TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 5 P1
INTERVAL_PARTITION SYS_P11645 TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 6 P2
INTERVAL_PARTITION SYS_P11646 TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 7 P1
INTERVAL_PARTITION SYS_P11647 TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 8 P2
INTERVAL_PARTITION SYS_P11648 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 9 P1
INTERVAL_PARTITION SYS_P11649 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 10 P2
INTERVAL_PARTITION SYS_P11650 TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 11 P1
INTERVAL_PARTITION SYS_P11651 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 12 P2
C1 C3
---------- ----------
0 2010-01-01
C1 C3
---------- ----------
1 2010-02-01
C1 C3
---------- ----------
2 2010-03-01
C1 C3
---------- ----------
3 2010-04-01
C1 C3
---------- ----------
4 2010-05-01
.
C1 C3
---------- ----------
11 2010-12-01
------------------------------------------------------------
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,PARTITION_POSITION,TABLESPACE_NAME,NUM_ROWS from user_tab_partitions where TABLE_NAME='INTERVAL_PARTITION';
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
---------------------------- ---------------------- ---------------------------------------------------------------------------------------------------------------------------- ------------------ --------------- ----------
INTERVAL_PARTITION PART2010_01 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1 PART 1
INTERVAL_PARTITION PART2010_02 TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2 PART 1
INTERVAL_PARTITION SYS_P11642 TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 3 P1 1
INTERVAL_PARTITION SYS_P11643 TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 4 P2 1
INTERVAL_PARTITION SYS_P11644 TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 5 P1 1
INTERVAL_PARTITION SYS_P11645 TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 6 P2 1
INTERVAL_PARTITION SYS_P11646 TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 7 P1 1
INTERVAL_PARTITION SYS_P11647 TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 8 P2 1
INTERVAL_PARTITION SYS_P11648 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 9 P1 1
INTERVAL_PARTITION SYS_P11649 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 10 P2 1
INTERVAL_PARTITION SYS_P11650 TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 11 P1 1
INTERVAL_PARTITION SYS_P11651 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 12 P2 1
INTERVAL_PARTITION SYS_P11652 TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 13 P1 1
INTERVAL_PARTITION SYS_P11653 TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 14 P2 1
INTERVAL_PARTITION SYS_P11654 TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 15 P3 1
INTERVAL_PARTITION SYS_P11655 TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 16 P1 1
INTERVAL_PARTITION SYS_P11656 TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 17 P2 1
INTERVAL_PARTITION SYS_P11657 TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 18 P3 1
INTERVAL_PARTITION SYS_P11658 TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 19 P1 1
INTERVAL_PARTITION SYS_P11659 TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 20 P2 1
INTERVAL_PARTITION SYS_P11660 TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 21 P3 1
INTERVAL_PARTITION SYS_P11661 TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 22 P1 1
INTERVAL_PARTITION SYS_P11662 TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 23 P2 1
INTERVAL_PARTITION SYS_P11663 TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 24 P3 1
INTERVAL_PARTITION SYS_P11664 TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 25 P1
Table altered.
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,PARTITION_POSITION,TABLESPACE_NAME,NUM_ROWS from user_tab_partitions where TABLE_NAME='INTERVAL_PARTITION';
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ --------------- ----------
INTERVAL_PARTITION PART2010_01 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1 PART 1
INTERVAL_PARTITION PART2010_02 TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2 PART 1
INTERVAL_PARTITION SYS_P11642 TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 3 P1 1
INTERVAL_PARTITION SYS_P11643 TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 4 P2 1
INTERVAL_PARTITION SYS_P11644 TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 5 P1 1
INTERVAL_PARTITION SYS_P11645 TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 6 P2 1
INTERVAL_PARTITION SYS_P11646 TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 7 P1 1
INTERVAL_PARTITION SYS_P11647 TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 8 P2 1
INTERVAL_PARTITION SYS_P11648 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 9 P1 1
INTERVAL_PARTITION SYS_P11649 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 10 P2 1
INTERVAL_PARTITION SYS_P11650 TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 11 P1 1
INTERVAL_PARTITION SYS_P11651 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 12 P2 1
INTERVAL_PARTITION SYS_P11652 TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 13 P1 1
INTERVAL_PARTITION SYS_P11653 TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 14 P2 1
INTERVAL_PARTITION SYS_P11654 TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 15 P3 1
INTERVAL_PARTITION SYS_P11655 TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 16 P1 1
INTERVAL_PARTITION SYS_P11656 TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 17 P2 1
INTERVAL_PARTITION SYS_P11657 TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 18 P3 1
INTERVAL_PARTITION SYS_P11658 TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 19 P1 1
INTERVAL_PARTITION SYS_P11659 TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 20 P2 1
INTERVAL_PARTITION SYS_P11660 TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 21 P3 1
INTERVAL_PARTITION SYS_P11661 TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 22 P1 1
INTERVAL_PARTITION SYS_P11662 TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 23 P2 1
INTERVAL_PARTITION SYS_P11663 TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 24 P3 1
INTERVAL_PARTITION SYS_P11664 TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 25 P1 1
C1 C3
---------- ------------
10 01-DEC-11
SQL> select * from INTERVAL_PARTITION partition(SYS_P11660);
C1 C3
---------- ------------
7 01-SEP-11
SQL> select * from INTERVAL_PARTITION partition(SYS_P11657);
C1 C3
---------- ------------
4 01-JUN-11
SQL> select * from INTERVAL_PARTITION partition(SYS_P11654);
C1 C3
---------- ------------
1 01-MAR-11
2.插入新資料,看看新分割槽是否還存放在P3表空間
SQL> select TABLE_NAME,PARTITION_NAME,HIGH_VALUE,PARTITION_POSITION,TABLESPACE_NAME,NUM_ROWS from user_tab_partitions where TABLE_NAME='INTERVAL_PARTITION';
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ --------------- ----------
INTERVAL_PARTITION PART2010_01 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1 PART 1
INTERVAL_PARTITION PART2010_02 TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2 PART 1
INTERVAL_PARTITION SYS_P11642 TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 3 P1 1
INTERVAL_PARTITION SYS_P11643 TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 4 P2 1
INTERVAL_PARTITION SYS_P11644 TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 5 P1 1
INTERVAL_PARTITION SYS_P11645 TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 6 P2 1
INTERVAL_PARTITION SYS_P11646 TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 7 P1 1
INTERVAL_PARTITION SYS_P11647 TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 8 P2 1
INTERVAL_PARTITION SYS_P11648 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 9 P1 1
INTERVAL_PARTITION SYS_P11649 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 10 P2 1
INTERVAL_PARTITION SYS_P11650 TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 11 P1 1
INTERVAL_PARTITION SYS_P11651 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 12 P2 1
INTERVAL_PARTITION SYS_P11652 TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 13 P1 1
INTERVAL_PARTITION SYS_P11653 TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 14 P2 1
INTERVAL_PARTITION SYS_P11654 TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 15 P3 1
INTERVAL_PARTITION SYS_P11655 TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 16 P1 1
INTERVAL_PARTITION SYS_P11656 TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 17 P2 1
INTERVAL_PARTITION SYS_P11657 TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 18 P3 1
INTERVAL_PARTITION SYS_P11658 TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 19 P1 1
INTERVAL_PARTITION SYS_P11659 TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 20 P2 1
INTERVAL_PARTITION SYS_P11660 TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 21 P3 1
INTERVAL_PARTITION SYS_P11661 TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 22 P1 1
INTERVAL_PARTITION SYS_P11662 TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 23 P2 1
INTERVAL_PARTITION SYS_P11663 TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 24 P3 1
INTERVAL_PARTITION SYS_P11664 TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 25 P1 1
INTERVAL_PARTITION SYS_P11665 TO_DATE(' 2012-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 26 P2
INTERVAL_PARTITION SYS_P11666 TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 27 P1
INTERVAL_PARTITION SYS_P11667 TO_DATE(' 2012-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 28 P2
INTERVAL_PARTITION SYS_P11668 TO_DATE(' 2012-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 29 P1
INTERVAL_PARTITION SYS_P11669 TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 30 P2
INTERVAL_PARTITION SYS_P11670 TO_DATE(' 2012-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 31 P1
INTERVAL_PARTITION SYS_P11671 TO_DATE(' 2012-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 32 P2
INTERVAL_PARTITION SYS_P11672 TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 33 P1
INTERVAL_PARTITION SYS_P11673 TO_DATE(' 2012-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 34 P2
INTERVAL_PARTITION SYS_P11674 TO_DATE(' 2012-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 35 P1
INTERVAL_PARTITION SYS_P11675 TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 36 P2
INTERVAL_PARTITION SYS_P11676 TO_DATE(' 2013-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 37 P1
Connected.
SQL> drop tablespace p3 including contents and datafiles;
drop tablespace p3 including contents and datafiles
*
ERROR at line 1:
ORA-14404: partitioned table contains partitions in a different tablespace
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ --------------- ----------
INTERVAL_PARTITION PART2010_01 TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1 PART 1
INTERVAL_PARTITION PART2010_02 TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2 PART 1
INTERVAL_PARTITION SYS_P11642 TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 3 P1 1
INTERVAL_PARTITION SYS_P11643 TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 4 P2 1
INTERVAL_PARTITION SYS_P11644 TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 5 P1 1
INTERVAL_PARTITION SYS_P11645 TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 6 P2 1
INTERVAL_PARTITION SYS_P11646 TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 7 P1 1
INTERVAL_PARTITION SYS_P11647 TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 8 P2 1
INTERVAL_PARTITION SYS_P11648 TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 9 P1 1
INTERVAL_PARTITION SYS_P11649 TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 10 P2 1
INTERVAL_PARTITION SYS_P11650 TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 11 P1 1
INTERVAL_PARTITION SYS_P11651 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 12 P2 1
INTERVAL_PARTITION SYS_P11652 TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 13 P1 1
INTERVAL_PARTITION SYS_P11653 TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 14 P2 1
INTERVAL_PARTITION SYS_P11654 TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 15 P1 1
INTERVAL_PARTITION SYS_P11655 TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 16 P1 1
INTERVAL_PARTITION SYS_P11656 TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 17 P2 1
INTERVAL_PARTITION SYS_P11657 TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 18 P1 1
INTERVAL_PARTITION SYS_P11658 TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 19 P1 1
INTERVAL_PARTITION SYS_P11659 TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 20 P2 1
INTERVAL_PARTITION SYS_P11660 TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 21 P1 1
INTERVAL_PARTITION SYS_P11661 TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 22 P1 1
INTERVAL_PARTITION SYS_P11662 TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 23 P2 1
INTERVAL_PARTITION SYS_P11663 TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 24 P1 1
INTERVAL_PARTITION SYS_P11664 TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 25 P1 1
INTERVAL_PARTITION SYS_P11665 TO_DATE(' 2012-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 26 P2
INTERVAL_PARTITION SYS_P11666 TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 27 P1
INTERVAL_PARTITION SYS_P11667 TO_DATE(' 2012-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 28 P2
INTERVAL_PARTITION SYS_P11668 TO_DATE(' 2012-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 29 P1
INTERVAL_PARTITION SYS_P11669 TO_DATE(' 2012-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 30 P2
INTERVAL_PARTITION SYS_P11670 TO_DATE(' 2012-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 31 P1
INTERVAL_PARTITION SYS_P11671 TO_DATE(' 2012-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 32 P2
INTERVAL_PARTITION SYS_P11672 TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 33 P1
INTERVAL_PARTITION SYS_P11673 TO_DATE(' 2012-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 34 P2
INTERVAL_PARTITION SYS_P11674 TO_DATE(' 2012-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 35 P1
INTERVAL_PARTITION SYS_P11675 TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 36 P2
INTERVAL_PARTITION SYS_P11676 TO_DATE(' 2013-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 37 P1
37 rows selected.
Connected.
SQL> drop tablespace p3 including contents and datafiles;
Tablespace dropped.
3.向P1表空間中的SYS_P11642 分割槽大量插入資料
---------- ------------
2 01-MAR-10
Table altered.
begin
for i in 0..27900040 loop
insert into INTERVAL_PARTITION values(i,to_date('2010-03-01','yyyy-mm-dd'));
end loop;
commit;
end;
/
FILE_NAME M
-------------------------------------------------- ----------
/u01/app/oradata/hou/users01.dbf 699.5
/u01/app/oradata/hou/undotbs01.dbf 1405
/u01/app/oradata/hou/sysaux01.dbf 613.0625
/u01/app/oradata/hou/system01.dbf 1170
/u01/app/oradata/hou/example01.dbf 100
/u01/app/oradata/hou/p1.dbf 531.5
/u01/app/oradata/hou/p2.dbf 10
/u01/app/oradata/hou/part01.dbf 70
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ ------------------------------ ----------
INTERVAL_PARTITION SYS_P11678 TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 39 P1 1
INTERVAL_PARTITION SYS_P11679 TO_DATE(' 2013-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 40 P2 1
INTERVAL_PARTITION SYS_P11680 TO_DATE(' 2013-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 41 P1 1
INTERVAL_PARTITION SYS_P11681 TO_DATE(' 2013-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 42 P2 1
INTERVAL_PARTITION SYS_P11682 TO_DATE(' 2013-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 43 P1 1
INTERVAL_PARTITION SYS_P11683 TO_DATE(' 2013-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 44 P2 1
INTERVAL_PARTITION SYS_P11684 TO_DATE(' 2013-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 45 P1 1
INTERVAL_PARTITION SYS_P11685 TO_DATE(' 2013-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 46 P2 1
INTERVAL_PARTITION SYS_P11686 TO_DATE(' 2013-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 47 P1 1
INTERVAL_PARTITION SYS_P11687 TO_DATE(' 2014-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 48 P2 1
INTERVAL_PARTITION SYS_P11688 TO_DATE(' 2014-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 49 P1 1
insert into INTERVAL_PARTITION values(i,to_date('2010-03-01','yyyy-mm-dd'));
end loop;
commit;
end;
ERROR at line 1:
ORA-01688: unable to extend table PART.INTERVAL_PARTITION partition SYS_P11642 by 1024 in tablespace P1
ORA-06512: at line 3
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION TABLESPACE_NAME NUM_ROWS
-------------------- --------------- -------------------------------------------------------------------------------- ------------------ ------------------------------ ----------
INTERVAL_PARTITION SYS_P11690 TO_DATE(' 2014-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 51 P1
INTERVAL_PARTITION SYS_P11691 TO_DATE(' 2014-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 52 P2
INTERVAL_PARTITION SYS_P11692 TO_DATE(' 2014-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 53 P1
INTERVAL_PARTITION SYS_P11693 TO_DATE(' 2014-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 54 P2
INTERVAL_PARTITION SYS_P11694 TO_DATE(' 2014-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 55 P1
INTERVAL_PARTITION SYS_P11695 TO_DATE(' 2014-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 56 P2
INTERVAL_PARTITION SYS_P11696 TO_DATE(' 2014-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 57 P1
INTERVAL_PARTITION SYS_P11697 TO_DATE(' 2014-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 58 P2
INTERVAL_PARTITION SYS_P11698 TO_DATE(' 2014-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 59 P1
INTERVAL_PARTITION SYS_P11699 TO_DATE(' 2015-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 60 P2
INTERVAL_PARTITION SYS_P11700 TO_DATE(' 2015-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 61 P1
In versions prior to Oracle 11g, we were very likely to have faced the error shown below especially if we used range partitioning and the partition column was a date field.
We needed to ensure that we precreated all the partitions before hand based on the expected values of data that would be inserted (or updated) in a table.
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
While we could use the MAXVALUE clause to create a ‘catch-all’ partition, this would not help us when we would like to perform any partition maintenance operations based on a date range or if wanted to use the partitioning feature to perform some kind of data archiving at the partition level.
11g Interval Partitioning
In Oracle 11g, the creation of partitions (for range) is automated and partitions are created as and when needed and takes the task of managing the creation of new partitions from the DBA. All that is required is to define the interval criteria and create the first partition. Subsequent partitions are created automatically based on the interval criteria.
create table mypart (ename varchar2(20), doj date) partition by range (doj) INTERVAL (NUMTOYMINTERVAL(1,'YEAR')) STORE IN (tbs1,tbs2) (partition p_2009 values less than (to_date('01-JAN-2010','DD-MON-YYYY')) ) ;
Note the NUMTOYMINTERVAL is an SQL Funtion used to convert a number to an INTERVAL YEAR TO MONTH literal. The accepted values are ‘YEAR’ and ‘MONTH’.
The STORE IN clause will create in the partitions in a round robin manner in tablespaces tbs1 and tbs2 as we will see below.
Let us now insert some values into the table.
SQL> insert into mypart 2 values 3 ('Tom','21-SEP-2009'); 1 row created. SQL> insert into mypart 2 values 3 ('Joe','02-JAN-2010'); 1 row created.
What has happened after the second insert? – a new partition ‘SYS_P42′ has been created for the year 2010 with a high value of ’01-JAN-2011’.
The first partition that we had precreated has been created in the default tablespace USERS since no tablespace name has been prescribed and the new partition has been created in the tablespace TBS2. The next partition that comes along will be created in tablespace TBS1 and so on.
SQL> select partition_name,high_value from user_tab_partitions 2 where table_name='MYPART'; PARTITION_NAME HIGH_VALUE ------------------------------ -------------------------------------------------------------------------------- P_2009 TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SYS_P42 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SQL> select partition_name,tablespace_name from user_tab_partitions 2 where table_name='MYPART'; PARTITION_NAME TABLESPACE_NAME ------------------------------ ------------------------------ P_2009 USERS SYS_P43 TBS2
We can use the ALTER TABLE SET INTERVAL command to convert a range partitioned table to an interval partitioned table as shown below.
SQL> create table mypart2 (ename varchar2(20), doj date) partition by range (doj) (partition p_2009 values less than (to_date('01-JAN-2010','DD-MON-YYYY')) ) ; 2 3 4 5 6 Table created. SQL> alter table mypart2 2 SET INTERVAL (NUMTOYMINTERVAL(1,'YEAR'); Table altered.
We need to keep the following points in mind when using Interval Partitioning:
Interval型別的分割槽的store in屬性的表空間儲存在哪個表,或透過哪個檢視可以查詢呢?如何找到這個表呢?小麥苗透過10046事件找到了,是sys.INSERT_TSN_LIST$表。記錄一下:
CREATE TABLE TB_INTERVAL(time_col date)
PARTITION BY RANGE (time_col)
INTERVAL ( NUMTOYMINTERVAL(1, 'month')) STORE IN (APP1TBS, APP2TBS, IDXTBS, TS_LHR)
(PARTITION P0 VALUES LESS THAN (TO_DATE('1-1-2010', 'dd-mm-yyyy')));
點選(此處)摺疊或開啟
-
[oracle@rhel6lhr ~]$ sqlplus / as sysdba
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 13 00:38:39 2017
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
-
and Real Application Testing options
-
-
SYS@orclasm > ALTER SESSION SET EVENTS '10046 trace name context forever,level 12';
-
-
Session altered.
-
-
SYS@orclasm > alter table lhr.TB_INTERVAL set store in (APP1TBS, APP2TBS, IDXTBS);
-
-
Table altered.
-
-
SYS@orclasm > ALTER SESSION SET EVENTS '10046 trace name context off';
-
-
Session altered.
-
-
SYS@orclasm > SELECT VALUE FROM V$DIAG_INFO;
-
-
VALUE
-
--------------------------------------------------------------------------------
-
TRUE
-
/u01/app/oracle
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/trace
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/alert
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/incident
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/cdump
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/hm
-
/u01/app/oracle/diag/rdbms/orclasm/orclasm/trace/orclasm_ora_28836.trc
-
0
-
0
-
-
11 rows selected.
-
- SYS@orclasm >
點選(此處)摺疊或開啟
-
[root@rhel6lhr ~]# tkprof /u01/app/oracle/diag/rdbms/orclasm/orclasm/trace/orclasm_ora_28836.trc
-
output = b.txt
-
-
TKPROF: Release 11.2.0.3.0 - Development on Thu Apr 13 00:41:19 2017
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
- [root@rhel6lhr ~]#
在b.txt中尋找update、delete、insert語句即可在b.txt的最後找到如下部分:
點選(此處)摺疊或開啟
-
delete from insert_tsn_list$
-
where
-
bo# = :1
-
-
-
-
insert into insert_tsn_list$ (bo#, position#, ts#)
-
values
-
(:1, :2, :3)
查詢該表即可驗證,該表記錄了interval分割槽的store in屬性值。則,查詢SQL如下:
點選(此處)摺疊或開啟
-
SELECT O.OBJECT_NAME,
-
(SELECT NAME FROM V$TABLESPACE TS WHERE TS.TS# = A.TS#) TS_NAME
-
FROM SYS.INSERT_TSN_LIST$ A, SYS.TS$ B, DBA_OBJECTS O
-
WHERE A.TS# = B.TS#
-
AND O.OBJECT_ID = A.BO#
-
AND O.OBJECT_NAME = 'TB_INTERVAL'
-
AND O.OWNER = 'LHR'
-
ORDER BY A.POSITION#;
-
-
-
-
SELECT O.OWNER, O.OBJECT_NAME, B.NAME TABLESPACE, O.OBJECT_TYPE
-
FROM SYS.INSERT_TSN_LIST$ A, SYS.TS$ B, DBA_OBJECTS O
-
WHERE A.TS# = B.TS#
-
AND O.OBJECT_ID = A.BO#
- ORDER BY A.POSITION#
點選(此處)摺疊或開啟
-
SYS@orclasm > SELECT O.OBJECT_NAME,
-
2 (SELECT NAME FROM V$TABLESPACE TS WHERE TS.TS# = A.TS#) TS_NAME
-
3 FROM SYS.INSERT_TSN_LIST$ A, SYS.TS$ B, DBA_OBJECTS O
-
4 WHERE A.TS# = B.TS#
-
5 AND O.OBJECT_ID = A.BO#
-
6 AND O.OBJECT_NAME = 'TB_INTERVAL'
-
7 AND O.OWNER = 'LHR'
-
8 ORDER BY A.POSITION#;
-
-
OBJECT_NAME TS_NAME
-
-------------------------------------------------------------------------------------------------------------------------------- ------------------------------
-
TB_INTERVAL APP1TBS
-
TB_INTERVAL APP2TBS
-
TB_INTERVAL IDXTBS
-
- SYS@orclasm >
將SYS.INSERT_TSN_LIST$拿到MOS中查詢,則查到了 (文件 ID 1594740.1),也說明了該問題。
Which Data Dictionary View Lists The Tablespace Rotation (STORE IN) For Interval Partitions? (文件 ID 1594740.1)
In this Document
Symptoms |
Changes |
Cause |
Solution |
References |
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.1.0.7 and laterInformation in this document applies to any platform.
SYMPTOMS
At present, there is no dictionary view available that holds information about the tablespaces specified as part of the STORE IN clause for interval partitioned tables.
CHANGES
None.
CAUSE
A bug report has been filed to fix this situation.
Bug 10080569 - STORE IN () DEFINITION OF INTERVAL PARTITIONING NOT IN DATA DICTIONARY VIEWS
SOLUTION
To work around this issue, you may define the following view to retrieve the information about the STORE IN () clause:
select o.owner, o.object_name, B.NAME tablespace , o.object_type
from sys.INSERT_TSN_LIST$ a, sys.ts$ b, dba_objects o
where A.TS# = b.ts#
and o.object_id = A.BO#
order by a.position#
REFERENCES
NOTE:1326111.1 - How Default Tablespace Works for an Interval Partition?
About Me
...............................................................................................................................
● 本文作者:小麥苗,只專注於資料庫的技術,更注重技術的運用
● 本文在itpub(http://blog.itpub.net/26736162)、部落格園(http://www.cnblogs.com/lhrbest)和個人微信公眾號(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/
● 本文部落格園地址:http://www.cnblogs.com/lhrbest
● 本文pdf版及小麥苗雲盤地址:http://blog.itpub.net/26736162/viewspace-1624453/
● QQ群:230161599 微信群:私聊
● 聯絡我請加QQ好友(646634621),註明新增緣由
● 於 2017-04-12 22:00 ~ 2017-04-13 03:00 在魔都完成
● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解
● 版權所有,歡迎分享本文,轉載請保留出處
...............................................................................................................................
拿起手機使用微信客戶端掃描下邊的左邊圖片來關注小麥苗的微信公眾號:xiaomaimiaolhr,掃描右邊的二維碼加入小麥苗的QQ群,學習最實用的資料庫技術。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2137151/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle Interval Partition 自動分割槽表-實驗Oracle
- Oracle11g INTERVAL分割槽新增分割槽策略Oracle
- INTERVAL分割槽表鎖分割槽操作
- Oracle 分割槽(partition)技術Oracle
- oracle 分割槽表總結Oracle
- Oracle 分割槽表 總結Oracle
- Oracle分割槽之五:建立分割槽索引總結Oracle索引
- oracle分割槽交換(exchange)技術Oracle
- Oracle表分割槽技術概述Oracle
- Oracle的分割槽索引技術Oracle索引
- oracle分割槽表總結(轉)Oracle
- ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表Oracle
- DATE型別INTERVAL分割槽型別
- Oracle分割槽表及分割槽索引Oracle索引
- Oracle Partition 分割槽詳細總結Oracle
- Oracle查詢Interval partition分割槽表內資料Oracle
- 使用Oracle Database 11g建立Interval分割槽表OracleDatabase
- 【INDEX】Oracle分割槽索引技術詳解IndexOracle索引
- 分割槽表總結
- 表分割槽總結
- 分割槽表 總結
- Oracle Interval Partition 預設分割槽重新命名-指令碼Oracle指令碼
- 範圍分割槽表和INTERVAL分割槽表對於SPLIT分割槽的區別
- 深入學習Oracle分割槽表及分割槽索引Oracle索引
- 全面認識oracle分割槽表及分割槽索引Oracle索引
- oracle分割槽partition及分割槽索引partition index(一)Oracle索引Index
- 【實驗】【PARTITION】RANGE分割槽表合併分割槽
- 【實驗】【PARTITION】RANGE分割槽表增加分割槽
- 【實驗】【PARTITION】RANGE分割槽表刪除分割槽
- Hive中靜態分割槽和動態分割槽總結Hive
- 分割槽表、分割槽索引和全域性索引部分總結索引
- MySQL 分割槽介紹總結MySql
- 定期truncate 歷史間隔分割槽INTERVAL PARTITION
- 11g分割槽新特性之interval partition
- Oracle Flashback 技術 總結Oracle
- Oracle Flashback技術總結Oracle
- 《RHEL6硬碟的分割槽和swap分割槽管理》——硬碟分割槽的大總結硬碟
- 【實驗】【PARTITION】RANGE分割槽建立