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

Oracle 10G Öеġ°»ØÊÕÕ¾¡±

·¢²¼Ê±¼ä:2006-06-09 10:06:14À´Ô´:ºìÁª×÷Õß:Çç
ÔÚOracle 10GÖÐ,ÒýÈëÁËÒ»¸ö»ØÊÕÕ¾(Recycle Bin)µÄ¸ÅÄî.

»ØÊÕÕ¾,´ÓÔ­ÀíÉÏÀ´Ëµ¾ÍÊÇÒ»¸öÊý¾Ý×Öµä±í,·ÅÖÃÓû§DropµôµÄÊý¾Ý¿â¶ÔÏóÐÅÏ¢.Óû§½øÐÐDrop²Ù×÷µÄ¶ÔÏ󣬲¢Ã»Óб»Êý¾Ý¿âɾ³ý,ÈÔÈ»»áÕ¼Óÿռä.³ý·ÇÊÇÓÉÓÚÓû§ÊÖ¹¤½øÐÐPurge»òÕßÒòΪ´æ´¢¿Õ¼ä²»¹»¶ø±»Êý¾Ý¿âÇåµô.Êý¾Ý¿âÓÐÁËÕâÑùµÄ¹¦ÄÜ,Äܹ»¼õÉٺܶ಻±ØÒªµÄÂé·³.³£³£¿´µ½¿ª·¢ÈËÔ±Îó°Ñ±íɾ³ý,¼±¼±Ã¦Ã¦ÕÒDBAÀ´Ïë°ì·¨µÄÇé¿ö,ÏàÐÅ,Ëæ×Å10GµÄ´ó·¶Î§Ó¦ÓÃ,ÕâÖÖÇéÐÎÓ¦¸Ã±È½ÏÉÙ¼ûÁË.

DBA¹ÜÀíÉϵÄÏà¹ØÐÅÏ¢¿ÉÒÔ´ÓUSER_recyclebin(DBA_recyclebin)ÖлñÈ¡.´ÓÏÖÔÚµÄBeta°æ±¾À´¿´,ÊÖ²áÉÏËù˵µÄͨ¹ýSQL*PlusµÄshow recycle bin ÃüÁî²é¿´»¹²»¿ÉÓÃ.

ΪÁ˱ãÓÚ²âÊÔ,ÎÒÃÇ´´½¨ÁËÒ»¸ö±í¿Õ¼äFoo,´óСΪ1M,´´½¨ÁËÒ»¸öÓû§Foo,ĬÈϵıí¿Õ¼äΪFoo.

SQL>; CONNECT foo/foo

ÒÑÁ¬½Ó¡£

SQL>; SELECT table_name FROM user_tables;

δѡ¶¨ÐÐ

SQL>; DESC user_recyclebin

Ãû³Æ ÊÇ·ñΪ¿Õ? ÀàÐÍ

user_recyclebin´ó¶àÊÇ×Ô½âÊ͵Ä,º­Òå±È½ÏÈÝÒ×Àí½â.

SQL>; SELECT object_name FROM user_recyclebin;

δѡ¶¨ÐÐ

SQL>; CREATE TABLE foo AS SELECT * FROM DUAL;

±íÒÑ´´½¨¡£

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

-----------------------------

FOO

SQL>; DROP TABLE foo;

±íÒѶªÆú¡£

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

------------------------------

RB$$41888$TABLE$0

SQL>;

SQL>; SELECT object_name, original_name FROM user_recyclebin;

OBJECT_NAME ORIGINAL_NAME

-------------------- --------------------

RB$$41888$TABLE$0 FOO

SQL>; DESC RB$$41888$TABLE$0

Ãû³Æ ÊÇ·ñΪ¿Õ? ÀàÐÍ

----------------------------------------- -------- -------------

DUMMY VARCHAR2(1)

µ±Ò»¸ö±í±»É¾³ý²¢Òƶ¯µ½"»ØÊÕÕ¾"ÖÐ,ËüµÄÃû×ÖÒª½øÐÐһЩת»».ÕâÑùµÄÄ¿µÄÏÔ¶øÒ×¼ûÊÇΪÁ˱ÜÃâͬÀà¶ÔÏóÃû³ÆµÄÖظ´.(WindowsÉÏ,¾­¹ýÁËÌØÊâµÄ´¦Àí,»ØÊÕÕ¾ÀïµÄ²Ù×÷ϵͳÎļþ¿ÉÒÔÖØÃû.)

ת»»ºóµÄÃû×Ö¸ñʽÈçÏÂ:

RB$$objn$object_type$version

ÆäÖеÄRB,´ú±íRecycle Bin. objnΪ±íµÄĿ¼¶ÔÏóºÅ. object_type±íʾ¶ÔÏóÀàÐÍ. version±íʾ°æ±¾ºÅ.ÓÉÊý¾Ý¿âÖ¸¶¨¡£foo±í±»É¾³ýºó£¬ÔÚÊý¾Ý¿â»ØÊÕÕ¾Àï±ä³ÉÁËRB$$41888$TABLE$0 ¡£´ÓÃû×Ö¿ÉÒÔ¿´³ö£¬Õâ¸ö¶ÔÏóµÄÀàÐÍÊÇTable£¬VersionÊÇ0.

SQL>; CREATE TABLE foo AS SELECT * FROM DUAL;

±íÒÑ´´½¨¡£

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

------------------------------

FOO

RB$$41888$TABLE$0

SQL>; DROP TABLE foo;

±íÒѶªÆú¡£

SQL>; SELECT object_name, original_name FROM user_recyclebin;

OBJECT_NAME ORIGINAL_NAME

-------------------- --------------------

RB$$41889$TABLE$0 FOO

RB$$41888$TABLE$0 FOO

ÄÜ¿´³öÀ´£¬ËäȻԴ±íÃû×ÖÏàͬ£¬ÔÚ»ØÊÕÕ¾ÀïµÄ¶ÔÏóÃû×ÖÊDz»Í¬µÄ¡£

ÒѾ­·Åµ½»ØÊÕÕ¾ÀïµÄ±íÊDz»ÄÜÓÃdrop ÃüÁîɾ³ýµÄ£º

SQL>; drop table RB$$41888$TABLE$0;

drop table RB$$41888$TABLE$0

*

ERROR λÓÚµÚ 1 ÐÐ:

ORA-38301: can not perform DDL/DML over objects in Recycle Bin

Èç¹ûÒªÇåµô¸Ä¶ÔÏó,ʹÓÃpurgeÃüÁ

SQL>; PURGE table RB$$41888$TABLE$0;

Table purged.

SQL>; SELECT object_name, original_name FROM user_recyclebin;

OBJECT_NAME ORIGINAL_NAME

-------------------- --------------------

RB$$41889$TABLE$0 FOO

¶ÔÏóÒѾ­Çåµô.

»Ö¸´±í,ʹÓÃUndropÃüÁî.

SQL>; undrop table RB$$41889$TABLE$0;

Table undropped.

SQL>; SELECT object_name, original_name FROM user_recyclebin;

δѡ¶¨ÐÐ

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

------------------------------

RB$$41889$TABLE$0

SQL>; desc foo;

ERROR:

ORA-04043: ¶ÔÏó foo ²»´æÔÚ

»Ö¸´ºóµÄ±íµÄÃû×ÖΪRB$$41889$TABLE$0,Èç¹ûÖ¸¶¨Ãû×Ö,ʹÓÃ" as ±íÃû×Ö "Èç: undrop table RB$$41889$TABLE$0 as FooÕâÑùµÄÓï¾ä.¸üΪÏêϸµÄÓï·¨,Çë²éÔÄ10GµÄSQL²Î¿¼ÊÖ²á.

SQL>; desc RB$$41889$TABLE$0;

Ãû³Æ ÊÇ·ñΪ¿Õ? ÀàÐÍ

DUMMY VARCHAR2(1)

SQL>; DROP TABLE RB$$41889$TABLE$0;

±íÒѶªÆú¡£

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

------------------------------

RB$$41889$TABLE$1

Èç¹ûÎÒÃÇÕâ¸öʱºòÔÙɾ³ýRB$$41889$TABLE$0£¬¿É¹Û²ìµ½»ØÊÕÕ¾Àï¸Ã±í°æ±¾ºÅµÄ±ä»¯¡£

Èç¹û¿Õ¼äÒ»Ö±¹»Ó㬻ØÊÕÕ¾ÀïµÄ¶ÔÏó»áÒ»Ö±±£³Ö£¨Èç¹ûÄã²»ÊÖ¹¤½øÐÐPurgeµÄ»°£©¡£Èç¹û¿Õ¼ä²»×㣬»ØÊÕÕ¾ÀïµÄ¶ÔÏó»á±»Çå¿Õ¡£¿´ÎÒÃÇÏÂÃæÕâ¸öÀý×Ó£º

ÈÃÎÒÃÇ´´½¨Ò»¸ö´óÒ»µãµÄ±í£º

SQL>; select object_name¡¡from user_recyclebin;

OBJECT_NAME

RB$$41893$TABLE$0

SQL>; CREATE TABLE foo_bigger AS SELECT * FROM all_objects WHERE ROWNUM<7980;

±íÒÑ´´½¨¡£

SQL>; SELECT table_name FROM user_tables;

TABLE_NAME

------------------------------

FOO_BIGGER

SQL>; SELECT object_name, original_name FROM user_recyclebin;

δѡ¶¨ÐÐ

Ŷ£¬¹ûÕ棬»ØÊÕÕ¾ÀïµÄÄÚÈÝÒѾ­±»É¾µôÁË¡£»¹Òª×¢Ò⣬Ôڿռ䲻×ãµÄʱºòDrop±í£¬Ò²ÊDz»Äܷŵ½»ØÊÕÕ¾ÀïµÄ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. dongyichen ÓÚ 2011-08-05 08:59:34·¢±í:

    ¹þ¹þ~×òÌì¸Õ¿´µ½Õâ¸ö»ØÊÕÕ¾~Â¥Ö÷Óмû¹ýdrop ±íºó£¬±í²»ÔÚrecyclebinÖеÄÇé¿öÂð£¿