---
title: "Oracle10g 回收站及彻底删除table : drop table xx purge "
author: "asdic"
date: "2009-02-16T14:49:13Z"
tags: ["C", "C#", "C++", "Oracle", "SQL"]
slug: "oracle10g-table-drop-table-xx-purge"
draft: false
lastmod: "2009-02-16T14:49:13Z"
id: 333570
url: "https://asdic.iteye.com/blog/333570"
---

\---------------------------------------------------------------

drop后的表被放在回收站(user\_recyclebin)里，而不是直接删除掉。这样，回收站里的表信息就可以被恢复，或彻底清除。

1.通过查询回收站user\_recyclebin获取被删除的表信息，然后使用语句

flashback table &lt;user\_recyclebin.object\_name or user\_recyclebin.original\_name&gt; to before drop \[rename to &lt;new\_table\_name&gt;];  
将回收站里的表恢复为原名称或指定新名称，表中数据不会丢失。  
若要彻底删除表，则使用语句：drop table &lt;table\_name&gt; purge;

2.清除回收站里的信息  
清除指定表：purge table &lt;table\_name&gt;;  
清除当前用户的回收站：purge recyclebin;  
清除所有用户的回收站：purge dba\_recyclebin;  
\===============================================================================  
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0  
Connected as test

SQL&gt; select * from test1;

A B C  
\-- -- ----------  
11 5  
11 10  
11 10  
13 10  
14 10  
15 10  
16 10  
17 10  
18 10  
19 10  
20 11

11 rows selected

SQL&gt; create table test2 as select * from test1;s

Table created

SQL&gt; select * from test2;

A B C  
\-- -- ----------  
11 5  
11 10  
11 10  
13 10  
14 10  
15 10  
16 10  
17 10  
18 10  
19 10  
20 11

11 rows selected

SQL&gt; drop table test2;

Table dropped

SQL&gt; select object\_name, original\_name, operation, type from user\_recyclebin;

OBJECT\_NAME ORIGINAL\_NAME OPERATION TYPE  
\------------------------------ -------------------------------- --------- -------------------------  
BIN$g5jFmA/OShC6+wsWKJiv2w==$0 TEST1 DROP TABLE  
BIN$vQwemDg4R9mK9fYJNdYzvg==$0 TEST2 DROP TABLE

SQL&gt; flashback table test2 to before drop rename to test3;--【to test3】将表重命名

Done

SQL&gt; select * from test3;

A B C  
\-- -- ----------  
11 5  
11 10  
11 10  
13 10  
14 10  
15 10  
16 10  
17 10  
18 10  
19 10  
20 11

11 rows selected

SQL&gt; select * from test2;

select * from test2

ORA-00942: 表或视图不存在

--彻底删除表  
SQL&gt; drop table test3 purge;

Table dropped

SQL&gt; select * from user\_recyclebin where original\_name = 'TEST3';

OBJECT\_NAME ORIGINAL\_NAME OPERATION TYPE TS\_NAME CREATETIME DROPTIME DROPSCN PARTITION\_NAME CAN\_UNDROP CAN\_PURGE RELATED BASE\_OBJECT PURGE\_OBJECT SPACE  
\------------------------------ -------------------------------- --------- ------------------------- ------------------------------ ------------------- ------------------- ------- -------------------------------- ---------- --------- ------- ----------- ------------ -----

SQL&gt; select * from user\_recyclebin;

OBJECT\_NAME ORIGINAL\_NAME OPERATION TYPE TS\_NAME CREATETIME DROPTIME DROPSCN PARTITION\_NAME CAN\_UNDROP CAN\_PURGE RELATED BASE\_OBJECT PURGE\_OBJECT SPACE  
\------------------------------ -------------------------------- --------- ------------------------- ------------------------------ ------------------- ------------------- ------- -------------------------------- ---------- --------- ------- ----------- ------------ -----  
BIN$g5jFmA/OShC6+wsWKJiv2w==$0 TEST1 DROP TABLE TP\_TEST1 2007-08-23:07:57:28 2007-08-23:07:58:51 1411156 YES YES 53086 53086 53086 896

--清除回收站里的表信息test1  
SQL&gt; purge table test1;

Done

SQL&gt; select * From user\_recyclebin;

OBJECT\_NAME ORIGINAL\_NAME OPERATION TYPE TS\_NAME CREATETIME DROPTIME DROPSCN PARTITION\_NAME CAN\_UNDROP CAN\_PURGE RELATED BASE\_OBJECT PURGE\_OBJECT SPACE  
\------------------------------ -------------------------------- --------- ------------------------- ------------------------------ ------------------- ------------------- ------- -------------------------------- ---------- --------- ------- ----------- ------------ -----