PURGE
Purpose
Use the PURGE statement to remove a table or index from your recycle bin and release all of the space associated with the object, or to remove the entire recycle bin, or to remove part of all of a dropped tablespace from the recycle bin.
使用PURGE語句從回收站刪除一個表或索引,並釋放與該對象關聯的所有空間,或者刪除整個回收站,或者刪除回收站中丟棄的表空間的一部分。
Caution:
You cannot roll back a PURGE statement, nor can you recover an object after it is purged.
注意:purge后不能回滾和恢復
To see the contents of your recycle bin, query the USER_RECYCLEBIN data dictionary review. You can use the RECYCLEBIN synonym instead. The following two statements return the same rows:
要查看回收站的內容,請查詢user_UNK clebin數據字典評審。可以使用回收的同義詞。
以下兩個語句返回相同的行:
SELECT * FROM RECYCLEBIN;
SELECT * FROM USER_RECYCLEBIN;
Prerequisites(先決條件)
The database object must reside in your own schema or you must have the DROP ANY... system privilege for the type of object to be purged, or you must have the SYSDBA system privilege.
數據庫對象必須駐留在自己的模式中,否則您必須DROP ANY…要清除的對象類型的系統特權,或者必須具有SYSDBA權限
Syntax(語法)
TABLE or INDEX
Specify the name of the table or index in the recycle bin that you want to purge. You can specify either the original user-specified name or the system-generated name Oracle Database assigned to the object when it was dropped.
指定要清除的回收站中的表或索引的名稱。可以指定原始用戶指定的名稱或系統生成的名稱Oracle數據庫,該數據庫被丟棄時指定給該對象。
• If you specify the user-specified name, and if the recycle bin contains more than one object of that name, then the database purges the object that has been in the recycle bin the longest.
如果指定用戶指定的名稱,並且如果回收站包含不止一個該名稱的對象,那么數據庫就會清除在回收站中最長的對象。
• System-generated recycle bin object names are unique. Therefore, if you specify the system-generated name, then the database purges that specified object.
系統生成的回收站對象名是唯一的。因此,如果指定系統生成的名稱,那么數據庫就會清除指定的對象。
When the database purges a table, all table partitions, LOBs and LOB partitions, indexes, and other dependent objects of that table are also purged.
當數據庫清理一個表時,所有表分區、LOB和LOB分區、索引以及該表的其他相關對象也被清除。
RECYCLEBIN
Use this clause to purge the current user's recycle bin. Oracle Database will remove all objects from the user's recycle bin and release all space associated with objects in the recycle bin.
使用此子句清除當前用戶的回收站。Oracle數據庫將刪除用戶回收站中的所有對象,並釋放與回收站中的對象相關的所有空間。
DBA_RECYCLEBIN
This clause is valid only if you have SYSDBA system privilege. It lets you remove all objects from the system-wide recycle bin, and is equivalent to purging the recycle bin of every user. This operation is useful, for example, before backward migration.
此條款僅當擁有SYSDBA系統特權時才有效。它允許從系統范圍內的回收站中刪除所有對象,並且相當於清除每個用戶的回收站。例如,該操作在向后遷移之前是有用的。
TABLESPACE tablespace
Use this clause to purge all the objects residing in the specified tablespace from the recycle bin.
使用此子句將所有駐留在指定表空間中的對象從回收站中清除。
USER user
Use this clause to reclaim space in a tablespace for a specified user. This operation is useful when a particular user is running low on disk quota for the specified tablespace.
用戶使用此子句在指定用戶的表空間中回收空間。當特定的用戶在指定的表空間上運行低磁盤配額時,此操作非常有用。
Examples
Remove a File From Your Recycle Bin: Example The following statement removes the table test from the recycle bin. If more than one version of test resides in the recycle bin, Oracle Database removes the version that has been there the longest:
從回收站刪除一個文件:例如下面的語句從回收站刪除了表測試。如果多個版本的測試駐留在回收站中,Oracle數據庫刪除了在那里最長的版本:
PURGE TABLE test;
To determine system-generated name of the table you want removed from your recycle bin, issue a SELECT statement on your recycle bin. Using that object name, you can remove the table by issuing a statement similar to the following statement. (The system-generated name will differ from the one shown in the example.)
要確定從回收站中刪除的表的系統生成的名稱,請在回收站上發布一個SELECT語句。使用該對象名稱,可以通過發出類似以下語句的語句刪除表。(系統生成的名稱與示例中顯示的名稱不同)。
PURGE TABLE RB$$33750$TABLE$0;
Remove the Contents of Your Recycle Bin: Example
刪除回收站的內容:例如
To remove the entire contents of your recycle bin, issue the following statement:
刪除回收箱的全部內容
PURGE RECYCLEBIN;
示例:
1) 首先查一下回收站:
Select * From RECYCLEBIN;
2)創建並刪除同一表三次:
CREATE TABLE recycle_tmp(version NUMBER(10)); INSERT INTO recycle_tmp VALUES(1); COMMIT; SELECT * FROM RECYCLE_TMP; DROP TABLE recycle_tmp; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
此時回收站只有一條記錄:
再重復2)的操作,此時回收站有兩條記錄:
CREATE TABLE recycle_tmp(version NUMBER(10)); INSERT INTO recycle_tmp VALUES(2); COMMIT; DROP TABLE recycle_tmp; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
3)清空版本1(默認刪除最早版本)
PURGE TABLE recycle_tmp; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
4)清空版本2(根據回收站OBJECT_NAME清除表)
PURGE TABLE "BIN$jw65nLiqSTO82jqDOGghDg==$0"; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
5)還原版本(使用閃回flashback)
FLASHBACK TABLE recycle_tmp TO BEFORE DROP; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
此時回收站已空
6)刪除版本3,后清空回收站
DROP TABLE recycle_tmp; PURGE RECYCLEBIN; SELECT object_name, original_name, operation, droptime FROM RECYCLEBIN;
回收站以清空