表丢弃时,回收站中的额外条目

时间:2014-02-11 05:29:12

标签: oracle

我创建了一个表TESTTABLE28enter image description here

然后我放弃了桌子。DROP TABLE TESTTABLE28; show parameter recyclebin;值设置为on。 当我查看Recycle Bin时,会列出其他一些条目以及TESTTABLE28

enter image description here

flashback table TESTTABLE28 to before drop;恢复表后,这些额外的条目也会被移动。 当我删除另一个只有TESTTABLE31列的varchar2个表时,这个值是什么以及为什么没有来?

更新

另外,如何恢复现在显示constraints而不是BIN$5lpccCurTNWwCbOSxCK29w==$1的{​​{1}}。

1 个答案:

答案 0 :(得分:2)

因为您的表中有LOB列,所以还有段和索引:

SQL> create table t_lb (x int, y clob, z blob);

SQL> col column_name format a10
SQL> col segment_name format a30
SQL> col index_name format a30
SQL> select column_name, segment_name, index_name from user_lobs
  2  where table_name = 'T_LB'
  3  /

COLUMN_NAM SEGMENT_NAME                   INDEX_NAME                            
---------- ------------------------------ ------------------------------        
Y          SYS_LOB0000701495C00002$$      SYS_IL0000701495C00002$$              
Z          SYS_LOB0000701495C00003$$      SYS_IL0000701495C00003$$              

SQL> show parameter recyclebin

NAME                                 TYPE        VALUE                          
------------------------------------ ----------- ------------------------------ 
recyclebin                           string      ON                             
SQL> drop table t_lb;

SQL> col object_name format a30
SQL> col type format a30
SQL> select object_name, type from recyclebin
  2  /

OBJECT_NAME                    TYPE                                             
------------------------------ ------------------------------                   
BIN$8hw9X/AeBmngQ0QTGKxsAQ==$0 TABLE                                            
SYS_LOB0000701495C00003$$      LOB                                              
SYS_LOB0000701495C00002$$      LOB                                              
SYS_IL0000701495C00003$$       LOB INDEX                                        
SYS_IL0000701495C00002$$       LOB INDEX    

从约束/索引恢复开始 - 你应该重命名它们:

SQL> create table t (x int, constraint t_pk primary key(x))
  2  /

SQL> drop table t;


SQL> select object_name, type from recyclebin;

OBJECT_NAME                    TYPE                                             
------------------------------ ------------------------------                   
BIN$8hw9X/AiBmngQ0QTGKxsAQ==$0 TABLE                                            
BIN$8hw9X/AhBmngQ0QTGKxsAQ==$0 INDEX                                            

SQL> flashback table t to before drop;

SQL> select constraint_name, index_name, constraint_type from
  2  user_constraints where table_name = 'T';

CONSTRAINT_NAME                INDEX_NAME                     C                 
------------------------------ ------------------------------ -                 
BIN$8hw9X/AgBmngQ0QTGKxsAQ==$0 BIN$8hw9X/AhBmngQ0QTGKxsAQ==$0 P                 

SQL> begin
  2   for cur in (select constraint_name, index_name
  3    from user_constraints where table_name = 'T'
  4  and constraint_type = 'P') loop
  5   execute immediate
  6  'alter table t rename constraint "'||cur.constraint_name||
  7  '" to t_pk';
  8  execute immediate
  9  'alter index "'||cur.index_name||'" rename to t_pk';
 10  end loop;
 11  end;
 12  /


SQL> select constraint_name, index_name from user_constraints
  2  where table_name = 'T';

CONSTRAINT_NAME                INDEX_NAME                                       
------------------------------ ------------------------------                   
T_PK                           T_PK