ºìÁªLinuxÃÅ»§
Linux°ïÖú

OracleÊý¾Ý¿â·ÖÇø±í²Ù×÷·½·¨

·¢²¼Ê±¼ä:2006-07-17 09:08:51À´Ô´:ºìÁª×÷Õß:thej
¡¡¡¡ÕªÒª£ºÔÚ´óÁ¿ÒµÎñÊý¾Ý´¦ÀíµÄÏîÄ¿ÖУ¬¿ÉÒÔ¿¼ÂÇʹÓ÷ÖÇø±íÀ´Ìá¸ßÓ¦ÓÃϵͳµÄÐÔÄܲ¢·½±ãÊý¾Ý¹ÜÀí£¬±¾ÎÄÏêϸ½éÉÜÁË·ÖÇø±íµÄʹÓá£

¡¡¡¡ ÔÚ´óÐ͵ÄÆóÒµÓ¦ÓûòÆóÒµ¼¶µÄÊý¾Ý¿âÓ¦ÓÃÖУ¬Òª´¦ÀíµÄÊý¾ÝÁ¿Í¨³£¿ÉÒÔ´ïµ½¼¸Ê®µ½¼¸°ÙGB£¬ÓеÄÉõÖÁ¿ÉÒÔµ½TB¼¶¡£ËäÈ»´æ´¢½éÖʺÍÊý¾Ý´¦Àí¼¼ÊõµÄ·¢Õ¹Ò²ºÜ¿ì£¬µ«ÊÇÈÔÈ»²»ÄÜÂú×ãÓû§µÄÐèÇó£¬ÎªÁËʹÓû§µÄ´óÁ¿µÄÊý¾ÝÔÚ¶Áд²Ù×÷ºÍ²éѯÖÐËٶȸü¿ì£¬OracleÌṩÁ˶ԱíºÍË÷Òý½øÐзÖÇøµÄ¼¼Êõ£¬ÒÔ¸ÄÉÆ´óÐÍÓ¦ÓÃϵͳµÄÐÔÄÜ¡£

¡¡¡¡ ʹÓ÷ÖÇøµÄÓŵ㣺

¡¡¡¡ ?ÔöÇ¿¿ÉÓÃÐÔ£ºÈç¹û±íµÄij¸ö·ÖÇø³öÏÖ¹ÊÕÏ£¬±íÔÚÆäËû·ÖÇøµÄÊý¾ÝÈÔÈ»¿ÉÓã»

¡¡¡¡ ?ά»¤·½±ã£ºÈç¹û±íµÄij¸ö·ÖÇø³öÏÖ¹ÊÕÏ£¬ÐèÒªÐÞ¸´Êý¾Ý£¬Ö»ÐÞ¸´¸Ã·ÖÇø¼´¿É£»

¡¡¡¡ ?¾ùºâI/O£º¿ÉÒ԰Ѳ»Í¬µÄ·ÖÇøÓ³Éäµ½´ÅÅÌÒÔƽºâI/O£¬¸ÄÉÆÕû¸öϵͳÐÔÄÜ£»

¡¡¡¡ ?¸ÄÉƲéѯÐÔÄÜ£º¶Ô·ÖÇø¶ÔÏóµÄ²éѯ¿ÉÒÔ½öËÑË÷×Ô¼º¹ØÐĵķÖÇø£¬Ìá¸ß¼ìË÷Ëٶȡ£

¡¡¡¡ OracleÊý¾Ý¿âÌṩ¶Ô±í»òË÷ÒýµÄ·ÖÇø·½·¨ÓÐÈýÖÖ£º

¡¡¡¡ ?·¶Î§·ÖÇø

¡¡¡¡ ?Hash·ÖÇø£¨É¢ÁзÖÇø£©

¡¡¡¡ ?¸´ºÏ·ÖÇø

¡¡¡¡ ÏÂÃ潫ÒÔʵÀýµÄ·½Ê½·Ö±ð¶ÔÕâÈýÖÖ·ÖÇø·½·¨À´ËµÃ÷·ÖÇø±íµÄʹÓá£ÎªÁ˲âÊÔ·½±ã£¬ÎÒÃÇÏȽ¨Èý¸ö±í¿Õ¼ä¡£
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

create tablespace dinya_space01
datafile ¡¯/test/demo/oracle/demodata/dinya01.dnf¡¯ size 50M
create tablespace dinya_space01
datafile ¡¯/test/demo/oracle/demodata/dinya02.dnf¡¯ size 50M
create tablespace dinya_space01
datafile ¡¯/test/demo/oracle/demodata/dinya03.dnf¡¯ size 50M

¡¡¡¡1.1. ·ÖÇø±íµÄ´´½¨

¡¡¡¡ 1.1.1. ·¶Î§·ÖÇø

¡¡¡¡ ·¶Î§·ÖÇø¾ÍÊǶÔÊý¾Ý±íÖеÄij¸öÖµµÄ·¶Î§½øÐзÖÇø£¬¸ù¾Ýij¸öÖµµÄ·¶Î§£¬¾ö¶¨½«¸ÃÊý¾Ý´æ´¢ÔÚÄĸö·ÖÇøÉÏ¡£Èç¸ù¾ÝÐòºÅ·ÖÇø£¬¸ù¾ÝÒµÎñ¼Ç¼µÄ´´½¨ÈÕÆÚ½øÐзÖÇøµÈ¡£

¡¡¡¡ ÐèÇóÃèÊö£ºÓÐÒ»¸öÎïÁϽ»Ò×±í£¬±íÃû£ºmaterial_transactions¡£¸Ã±í½«À´¿ÉÄÜÓÐǧÍò¼¶µÄÊý¾Ý¼Ç¼Êý¡£ÒªÇóÔÚ½¨¸Ã±íµÄʱºòʹÓ÷ÖÇø±í¡£ÕâʱºòÎÒÃÇ¿ÉÒÔʹÓÃÐòºÅ·ÖÇøÈý¸öÇø£¬Ã¿¸öÇøÖÐÔ¤¼Æ´æ´¢ÈýǧÍòµÄÊý¾Ý£¬Ò²¿ÉÒÔʹÓÃÈÕÆÚ·ÖÇø£¬ÈçÿÎåÄêµÄÊý¾Ý´æ´¢ÔÚÒ»¸ö·ÖÇøÉÏ¡£

¡¡¡¡ ¸ù¾Ý½»Ò׼ǼµÄÐòºÅ·ÖÇø½¨±í£º ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create table dinya_test
2 (
3 transaction_id number primary key,
4 item_id number(8) not null,
5 item_description varchar2(300),
6 transaction_date date not null
7 )
8 partition by range (transaction_id)
9 (
10 partition part_01 values less than(30000000) tablespace dinya_space01,
11 partition part_02 values less than(60000000) tablespace dinya_space02,
12 partition part_03 values less than(maxvalue) tablespace dinya_space03
13 );
Table created.

¡¡¡¡¡¡ ½¨±í³É¹¦£¬¸ù¾Ý½»Ò×µÄÐòºÅ£¬½»Ò×IDÔÚÈýǧÍòÒÔϵļǼ½«´æ´¢ÔÚµÚÒ»¸ö±í¿Õ¼ädinya_space01ÖУ¬·ÖÇøÃûΪ:par_01£¬ÔÚÈýǧÍòµ½ÁùǧÍòÖ®¼äµÄ¼Ç¼´æ´¢ÔÚµÚ¶þ¸ö±í¿Õ¼ä£º

¡¡¡¡ dinya_space02ÖУ¬·ÖÇøÃûΪ£ºpar_02£¬¶ø½»Ò×IDÔÚÁùǧÍòÒÔÉϵļǼ´æ´¢ÔÚµÚÈý¸ö±í¿Õ¼ädinya_space03ÖУ¬·ÖÇøÃûΪpar_03.

¡¡¡¡ ¸ù¾Ý½»Ò×ÈÕÆÚ·ÖÇø½¨±í£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create table dinya_test
2 (
3 transaction_id number primary key,
4 item_id number(8) not null,

5 item_description varchar2(300),
6 transaction_date date not null
7 )
8 partition by range (transaction_date)
9 (
10 partition part_01 values less than(to_date(¡¯2006-01-01¡¯,¡¯yyyy-mm-dd¡¯))
tablespace dinya_space01,
11 partition part_02 values less than(to_date(¡¯2010-01-01¡¯,¡¯yyyy-mm-dd¡¯))
tablespace dinya_space02,
12 partition part_03 values less than(maxvalue) tablespace dinya_space03
13 );
Table created.



¡¡¡¡ ÕâÑùÎÒÃǾͷֱð½¨ÁËÒÔ½»Ò×ÐòºÅºÍ½»Ò×ÈÕÆÚÀ´·ÖÇøµÄ·ÖÇø±í¡£Ã¿´Î²åÈëÊý¾ÝµÄʱºò£¬ÏµÍ³½«¸ù¾ÝÖ¸¶¨µÄ×ֶεÄÖµÀ´×Ô¶¯½«¼Ç¼´æ´¢µ½Öƶ¨µÄ·ÖÇø£¨±í¿Õ¼ä£©ÖС£

¡¡¡¡ µ±È»£¬ÎÒÃÇ»¹¿ÉÒÔ¸ù¾ÝÐèÇó£¬Ê¹ÓÃÁ½¸ö×ֶεķ¶Î§·Ö²¼À´·ÖÇø£¬Èçpartition by range ( transaction_id ,transaction_date), ·ÖÇøÌõ¼þÖеÄÖµÒ²×öÏàÓ¦µÄ¸Ä±ä£¬Çë¶ÁÕß×ÔÐвâÊÔ¡£

¡¡¡¡ 1.1.2. Hash·ÖÇø£¨É¢ÁзÖÇø£©

¡¡¡¡ É¢ÁзÖÇøΪͨ¹ýÖ¸¶¨·ÖÇø±àºÅÀ´¾ùÔÈ·Ö²¼Êý¾ÝµÄÒ»ÖÖ·ÖÇøÀàÐÍ£¬ÒòΪͨ¹ýÔÚI/OÉ豸ÉϽøÐÐÉ¢ÁзÖÇø£¬Ê¹µÃÕâЩ·ÖÇø´óСһÖ¡£È罫ÎïÁϽ»Ò×±íµÄÊý¾Ý¸ù¾Ý½»Ò×IDÉ¢Áеشæ·ÅÔÚÖ¸¶¨µÄÈý¸ö±í¿Õ¼äÖУº



ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create table dinya_test
2 (
3 transaction_id number primary key,
4 item_id number(8) not null,
5 item_description varchar2(300),
6 transaction_date date
7 )
8 partition by hash(transaction_id)
9 (
10 partition part_01 tablespace dinya_space01,
11 partition part_02 tablespace dinya_space02,
12 partition part_03 tablespace dinya_space03
13 );
Table created.

¡¡¡¡ ½¨±í³É¹¦£¬´Ëʱ²åÈëÊý¾Ý£¬ÏµÍ³½«°´transaction_id½«¼Ç¼ɢÁеزåÈëÈý¸ö·ÖÇøÖУ¬ÕâÀïÒ²¾ÍÊÇÈý¸ö²»Í¬µÄ±í¿Õ¼äÖС£

¡¡¡¡ 1.1.3. ¸´ºÏ·ÖÇø

¡¡¡¡ ÓÐʱºòÎÒÃÇÐèÒª¸ù¾Ý·¶Î§·ÖÇøºó£¬Ã¿¸ö·ÖÇøÄÚµÄÊý¾ÝÔÙÉ¢Áеطֲ¼ÔÚ¼¸¸ö±í¿Õ¼äÖУ¬ÕâÑùÎÒÃǾÍҪʹÓø´ºÏ·ÖÇø¡£¸´ºÏ·ÖÇøÊÇÏÈʹÓ÷¶Î§·ÖÇø£¬È»ºóÔÚÿ¸ö·ÖÇøÄÚÔÙʹÓÃÉ¢ÁзÖÇøµÄÒ»ÖÖ·ÖÇø·½·¨£¬È罫ÎïÁϽ»Ò׵ļǼ°´Ê±¼ä·ÖÇø£¬È»ºóÿ¸ö·ÖÇøÖеÄÊý¾Ý·ÖÈý¸ö×Ó·ÖÇø£¬½«Êý¾ÝÉ¢Áеش洢ÔÚÈý¸öÖ¸¶¨µÄ±í¿Õ¼äÖУº

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create table dinya_test
2 (
3 transaction_id number primary key,
4 item_id number(8) not null,
5 item_description varchar2(300),
6 transaction_date date
7 )
8 partition by range(transaction_date)subpartition by hash(transaction_id)
9 subpartitions 3 store in (dinya_space01,dinya_space02,dinya_space03)
10 (
11 partition part_01 values less than(to_date(¡¯2006-01-01¡¯,¡¯yyyy-mm-dd¡¯)),
12 partition part_02 values less than(to_date(¡¯2010-01-01¡¯,¡¯yyyy-mm-dd¡¯)),
13 partition part_03 values less than(maxvalue)
14 );
Table created.


¡¡¡¡ ¸ÃÀýÖУ¬ÏÈÊǸù¾Ý½»Ò×ÈÕÆÚ½øÐз¶Î§·ÖÇø£¬È»ºó¸ù¾Ý½»Ò×µÄID½«¼Ç¼ɢÁеش洢ÔÚÈý¸ö±í¿Õ¼äÖС£

¡¡¡¡1.2. ·ÖÇø±í²Ù×÷

¡¡¡¡ ÒÔÉÏÁ˽âÁËÈýÖÖ·ÖÇø±íµÄ½¨±í·½·¨£¬ÏÂÃ潫ʹÓÃʵ¼ÊµÄÊý¾Ý²¢Õë¶Ô°´ÈÕÆڵķ¶Î§·ÖÇøÀ´²âÊÔ·ÖÇø±íµÄÊý¾Ý¼Ç¼µÄ²Ù×÷¡£

¡¡¡¡ 1.2.1. ²åÈë¼Ç¼£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> insert into dinya_test values(1,12,¡¯BOOKS¡¯,sysdate);
1 row created.
SQL> insert into dinya_test values(2,12, ¡¯BOOKS¡¯,sysdate+30);
1 row created.

SQL> insert into dinya_test values(3,12, ¡¯BOOKS¡¯,to_date(¡¯2006-05-30¡¯,¡¯yyyy-mm-dd¡¯));
1 row created.
SQL> insert into dinya_test values(4,12, ¡¯BOOKS¡¯,to_date(¡¯2007-06-23¡¯,¡¯yyyy-mm-dd¡¯));
1 row created.
SQL> insert into dinya_test values(5,12, ¡¯BOOKS¡¯,to_date(¡¯2011-02-26¡¯,¡¯yyyy-mm-dd¡¯));
1 row created.
SQL> insert into dinya_test values(6,12, ¡¯BOOKS¡¯,to_date(¡¯2011-04-30¡¯,¡¯yyyy-mm-dd¡¯));
1 row created.
SQL> commit;
Commit complete.
SQL>

¡¡¡¡ °´ÉÏÃæµÄ½¨±í½á¹û£¬2006ÄêÇ°µÄÊý¾Ý½«´æ´¢ÔÚµÚÒ»¸ö·ÖÇøpart_01ÉÏ£¬¶ø2006Äêµ½2010ÄêµÄ½»Ò×Êý¾Ý½«´æ´¢ÔÚµÚ¶þ¸ö·ÖÇøpart_02ÉÏ£¬2010ÄêÒÔºóµÄ¼Ç¼´æ´¢ÔÚµÚÈý¸ö·ÖÇøpart_03ÉÏ¡£


¡¡¡¡ 1.2.2. ²éѯ·ÖÇø±í¼Ç¼£º ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> select * from dinya_test partition(part_01);
TRANSACTION_ID ITEM_ID ITEM_DESCRIPTION TRANSACTION_DATE
--------------------------------------------------------------------------------
1 12 BOOKS 2005-1-14 14:19:
2 12 BOOKS 2005-2-13 14:19:
SQL>
SQL> select * from dinya_test partition(part_02);
TRANSACTION_ID ITEM_ID ITEM_DESCRIPTION TRANSACTION_DATE
--------------------------------------------------------------------------------
3 12 BOOKS 2006-5-30
4 12 BOOKS 2007-6-23
SQL>
SQL> select * from dinya_test partition(part_03);
TRANSACTION_ID ITEM_ID ITEM_DESCRIPTION TRANSACTION_DATE
--------------------------------------------------------------------------------
5 12 BOOKS 2011-2-26
6 12 BOOKS 2011-4-30
SQL>

¡¡¡¡ ´Ó²éѯµÄ½á¹û¿ÉÒÔ¿´³ö£¬²åÈëµÄÊý¾ÝÒѾ­¸ù¾Ý½»Ò×ʱ¼ä·¶Î§´æ´¢ÔÚ²»Í¬µÄ·ÖÇøÖС£ÕâÀïÊÇÖ¸¶¨ÁË·ÖÇøµÄ²éѯ£¬µ±È»Ò²¿ÉÒÔ²»Ö¸¶¨·ÖÇø£¬Ö±½ÓÖ´ÐÐselect * from dinya_test²éѯȫ²¿¼Ç¼¡£

¡¡¡¡ ÔÚÒ²¼ìË÷µÄÊý¾ÝÁ¿ºÜ´óµÄʱºò£¬Ö¸¶¨·ÖÇø»á´ó´óÌá¸ß¼ìË÷Ëٶȡ£

¡¡¡¡ 1.2.3. ¸üзÖÇø±íµÄ¼Ç¼£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> update dinya_test partition(part_01) t set t.item_description=¡¯DESK¡¯ where
t.transaction_id=1;
1 row updated.
SQL> commit;
Commit complete.
SQL>

¡¡¡¡ ÕâÀォµÚÒ»¸ö·ÖÇøÖеĽ»Ò×ID=1µÄ¼Ç¼ÖеÄitem_description×ֶθüÐÂΪ¡°DESK¡±£¬¿ÉÒÔ¿´µ½ÒѾ­³É¹¦¸üÐÂÁËÒ»Ìõ¼Ç¼¡£µ«Êǵ±¸üеÄʱºòÖ¸¶¨ÁË·ÖÇø£¬¶ø¸ù¾Ý²éѯµÄ¼Ç¼²»Ôڸ÷ÖÇøÖÐʱ£¬½«²»»á¸üÐÂÊý¾Ý£¬Çë¿´ÏÂÃæµÄÀý×Ó£º ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> update dinya_test partition(part_01) t set t.item_description=¡¯DESK¡¯ where
t.transaction_id=6;
0 rows updated.
SQL> commit;
Commit complete.
SQL>

¡¡¡¡ Ö¸¶¨ÁËÔÚµÚÒ»¸ö·ÖÇøÖиüмǼ£¬µ«ÊÇÌõ¼þÖÐÏÞÖƽ»Ò×IDΪ6£¬¶ø²éѯȫ±í£¬½»Ò×IDΪ6µÄ¼Ç¼ÔÚµÚÈý¸ö·ÖÇøÖУ¬ÕâÑù¸ÃÌõÓï¾ä½«²»»á¸üмǼ¡£

¡¡¡¡ 1.2.4. ɾ³ý·ÖÇø±í¼Ç¼£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> delete from dinya_test partition(part_02) t where t.transaction_id=4;
1 row deleted.
SQL> commit;
Commit complete.
SQL>


¡¡¡¡ ÉÏÃæÀý×Óɾ³ýÁ˵ڶþ¸ö·ÖÇøpart_02ÖеĽ»Ò׼ǼIDΪ4µÄÒ»Ìõ¼Ç¼£¬ºÍ¸üÐÂÊý¾ÝÏàͬ£¬Èç¹ûÖ¸¶¨ÁË·ÖÇø£¬¶øÌõ¼þÖеÄÊý¾ÝÓÖ²»Ôڸ÷ÖÇøÖÐʱ£¬½«²»»áɾ³ýÈκÎÊý¾Ý¡£

¡¡¡¡1.3. ·ÖÇø±íË÷ÒýµÄʹÓãº

¡¡¡¡ ·ÖÇø±íºÍÒ»°ã±íÒ»Ñù¿ÉÒÔ½¨Á¢Ë÷Òý£¬·ÖÇø±í¿ÉÒÔ´´½¨¾Ö²¿Ë÷ÒýºÍÈ«¾ÖË÷Òý¡£µ±·ÖÇøÖгöÏÖÐí¶àÊÂÎñ²¢ÇÒÒª±£Ö¤ËùÓзÖÇøÖеÄÊý¾Ý¼Ç¼µÄΨһÐÔʱ²ÉÓÃÈ«¾ÖË÷Òý¡£

¡¡¡¡ 1.3.1. ¾Ö²¿Ë÷Òý·ÖÇøµÄ½¨Á¢£º


ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create index dinya_idx_t on dinya_test(item_id)
2 local
3 (
4 partition idx_1 tablespace dinya_space01,
5 partition idx_2 tablespace dinya_space02,
6 partition idx_3 tablespace dinya_space03
7 );
Index created.
SQL>

¡¡¡¡ ¿´²éѯµÄÖ´Ðмƻ®£¬´ÓÏÂÃæµÄÖ´Ðмƻ®¿ÉÒÔ¿´³ö£¬ÏµÍ³ÒѾ­Ê¹ÓÃÁËË÷Òý£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> select * from dinya_test partition(part_01) t where t.item_id=12;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=187)
1 0 TABLE ACCESS (BY LOCAL INDEX ROWID) OF ¡¯DINYA_TEST¡¯ (Cost=
2 Card=1 Bytes=187)
2 1 INDEX (RANGE SCAN) OF ¡¯DINYA_IDX_T¡¯ (NON-UNIQUE) (Cost=1
Card=1)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
334 bytes sent via SQL*Net to client
309 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client

1 sorts (memory)
0 sorts (disk)
2 rows processed
SQL>

¡¡¡¡ 1.3.2. È«¾ÖË÷Òý·ÖÇøµÄ½¨Á¢

¡¡¡¡ È«¾ÖË÷Òý½¨Á¢Ê±global ×Ó¾äÔÊÐíÖ¸¶¨Ë÷ÒýµÄ·¶Î§Öµ£¬Õâ¸ö·¶Î§ÖµÎªË÷Òý×ֶεķ¶Î§Öµ£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> create index dinya_idx_t on dinya_test(item_id)
2 global partition by range(item_id)
3 (
4 partition idx_1 values less than (1000) tablespace dinya_space01,
5 partition idx_2 values less than (10000) tablespace dinya_space02,
6 partition idx_3 values less than (maxvalue) tablespace dinya_space03
7 );
Index created.
SQL>

¡¡¡¡ ±¾ÀýÖжԱíµÄitem_id×ֶν¨Á¢Ë÷Òý·ÖÇø£¬µ±È»Ò²¿ÉÒÔ²»Ö¸¶¨Ë÷Òý·ÖÇøÃûÖ±½Ó¶ÔÕû¸ö±í½¨Á¢Ë÷Òý£¬È磺

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SQL> create index dinya_idx_t on dinya_test(item_id);
Index created.
SQL>

¡¡¡¡ ͬÑùµÄ£¬¶ÔÈ«¾ÖË÷Òý¸ù¾ÝÖ´Ðмƻ®¿ÉÒÔ¿´³öË÷ÒýÒѾ­¿ÉÒÔʹÓãº

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º

SQL> select * from dinya_test t where t.item_id=12;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=3 Bytes=561)
1 0 TABLE ACCESS (BY GLOBAL INDEX ROWID) OF ¡¯DINYA_TEST¡¯ (Cost
=2 Card=3 Bytes=561)
2 1 INDEX (RANGE SCAN) OF ¡¯DINYA_IDX_T¡¯ (NON-UNIQUE) (Cost=1
Card=3)
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
10 consistent gets
0 physical reads

0 redo size
420 bytes sent via SQL*Net to client
309 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
5 rows processed
SQL>

¡¡¡¡1.4. ·ÖÇø±íµÄά»¤£º

¡¡¡¡ Á˽âÁË·ÖÇø±íµÄ½¨Á¢¡¢Ë÷ÒýµÄ½¨Á¢¡¢±íºÍË÷ÒýµÄʹÓúó£¬ÔÚÓ¦ÓõĻ¹Òª¾­³£¶Ô·ÖÇø½øÐÐά»¤ºÍ¹ÜÀí¡£ÈÕ³£Î¬»¤ºÍ¹ÜÀíµÄÄÚÈÝ°üÀ¨£ºÔö¼ÓÒ»¸ö·ÖÇø£¬ºÏ²¢Ò»¸ö·ÖÇø¼°É¾³ý·ÖÇøµÈµÈ¡£ÏÂÃæÒÔ·¶Î§·ÖÇøΪÀý˵Ã÷Ôö¼Ó¡¢ºÏ²¢¡¢É¾³ý·ÖÇøµÄÒ»°ã²Ù×÷£º

¡¡¡¡ 1.4.1. Ôö¼ÓÒ»¸ö·ÖÇø:


ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SQL> alter table dinya_test
2 add partition part_04 values less than(to_date(¡¯2012-01-01¡¯,¡¯yyyy-mm-dd¡¯))
tablespace dinya_spa
ce03;
Table altered.
SQL>

¡¡¡¡ Ôö¼ÓÒ»¸ö·ÖÇøµÄʱºò£¬Ôö¼ÓµÄ·ÖÇøµÄÌõ¼þ±ØÐë´óÓÚÏÖÓзÖÇøµÄ×î´óÖµ£¬·ñÔòϵͳ½«ÌáʾORA-14074 partition bound must collate higher than that of the last partition ´íÎó¡£

¡¡¡¡ 1.4.2. ºÏ²¢Ò»¸ö·ÖÇø£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SQL> alter table dinya_test merge partitions part_01,part_02 into partition part_02;
Table altered.
SQL>

¡¡¡¡ ÔÚ±¾ÀýÖн«Ô­ÓеıíµÄpart_01·ÖÇøºÍpart_02·ÖÇø½øÐÐÁ˺ϲ¢£¬ºÏ²¢ºóµÄ·ÖÇøΪpart_02,Èç¹ûÔںϲ¢µÄʱºò°ÑºÏ²¢ºóµÄ·ÖÇø¶¨Îªpart_01µÄʱºò£¬ÏµÍ³½«ÌáʾORA-14275 cannot reuse lower-bound partition as resulting partition ´íÎó¡£

¡¡¡¡ 1.4.3. ɾ³ý·ÖÇø£º

ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SQL> alter table dinya_test drop partition part_01;
Table altered.
SQL>

¡¡¡¡ ɾ³ý·ÖÇø±íµÄÒ»¸ö·ÖÇøºó£¬²éѯ¸Ã±íµÄÊý¾ÝʱÏÔʾ£¬¸Ã·ÖÇøÖеÄÊý¾ÝÒÑÈ«²¿¶ªÊ§£¬ËùÒÔÖ´ÐÐɾ³ý·ÖÇø¶¯×÷ʱҪÉ÷ÖØ£¬È·±£Ïȱ¸·ÝÊý¾ÝºóÔÙÖ´ÐУ¬»ò½«·ÖÇøºÏ²¢¡£

¡¡¡¡1.5. ×ܽ᣺

¡¡¡¡ ÐèҪ˵Ã÷µÄÊÇ£¬±¾ÎÄÔÚ¾ÙÀý˵Ãû·ÖÇø±íÊÂÎñ²Ù×÷µÄʱºò£¬¶¼Ö¸¶¨ÁË·ÖÇø£¬ÒòΪָ¶¨ÁË·ÖÇø£¬ÏµÍ³ÔÚÖ´ÐеÄʱºòÔòÖ»²Ù×÷¸Ã·ÖÇøµÄ¼Ç¼£¬Ìá¸ßÁËÊý¾Ý´¦ÀíµÄËٶȡ£²»ÒªÖ¸¶¨·ÖÇøÖ±½Ó²Ù×÷Êý¾ÝÒ²ÊÇ¿ÉÒԵġ£ÔÚ·ÖÇø±íÉϽ¨Ë÷Òý¼°¶àË÷ÒýµÄʹÓúͷǷÖÇø±íÒ»Ñù¡£´ËÍ⣬ÒòΪÔÚά»¤·ÖÇøµÄʱºò¿ÉÄܶԷÖÇøµÄË÷Òý»á²úÉúÒ»¶¨µÄÓ°Ï죬¿ÉÄÜÐèÒªÔÚά»¤Ö®ºóÖؽ¨Ë÷Òý£¬Ïà¹ØÄÚÈÝÇë²Î¿¼·ÖÇø±íË÷Òý²¿·ÖµÄÎĵµ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ