25. Nov. 2008

Oracle Version 10g comes along with a new feature called Recyclebin. It is what it’s name is promising you – a bin collecting all the dropped objects and data for you. This recylebin is a prerequisite in order to have FLASHBACK DROP functionality and therefore provided to every Oracle user.

SQL> desc recyclebin
 Name                                      Null?    Type
 —————————————– ——– ————
 OBJECT_NAME                               NOT NULL VARCHAR2(30)
 ORIGINAL_NAME                                      VARCHAR2(32)
 OPERATION                                          VARCHAR2(9)
 TYPE                                               VARCHAR2(25)
 TS_NAME                                            VARCHAR2(30)
 CREATETIME                                         VARCHAR2(19)
 DROPTIME                                           VARCHAR2(19)
 DROPSCN                                            NUMBER
 PARTITION_NAME                                     VARCHAR2(32)
 CAN_UNDROP                                         VARCHAR2(3)
 CAN_PURGE                                          VARCHAR2(3)
 RELATED                                   NOT NULL NUMBER
 BASE_OBJECT                               NOT NULL NUMBER
 PURGE_OBJECT                              NOT NULL NUMBER
 SPACE                                              NUMBER

Perhaps important to know is that the recyclebin is a public synonym and it is based on the view user_recyclebin which in turn is based on sys.recyclebin$ table and does not work for SYS objects.

Comparing behavior as in 8i / 9i, there is no issues with DROPping the table behaviour wise in 10g . The space is not released immediately and is accounted for within the same tablespace / schema after the drop, but there is NO recycling of the objects when dropping a tablespace or user.

 SQL> DROP TABLE EMP;
Table dropped.

SQL> SELECT owner,original_name,operation,type
  2  FROM dba_recyclebin
  3  /

OWNER                          ORIGINAL_NAME                    OPERATION TYPE
—————————— ——————————– ——— ——
SCOTT                          EMP                              DROP      TABLE

Note: We can also create a new table with the same name at this point.

Freeing used space though:
In order to completely remove the table from the DB and to release the space the new PURGE command is used.

From SCOTT user:
SQL> PURGE TABLE EMP;
Table purged.

SQL> SHOW recyclebin
SQL>

But we can also DROP and PURGE a table with a single command

From SCOTT user:
SQL> DROP TABLE EMP PURGE;
Table dropped.

SQL> SELECT *
  2  FROM recyclebin
  3  /
no rows selected

So there will be no need to PURGE the table out of Recylebin later on and space is directly marked as free again.

Recylebin is for sure a usefully new feature of Oracle 10g, but rarely some Oracle user is used working with it today.  Based on your own or customers needs it might appear meaningful to deactive it though.

As for on Oracle 10gR2 recyclebin is an initialization parameter and by default its ON, but you can disable recyclebin by using the following commands:

SQL> ALTER SESSION SET recyclebin = OFF;
SQL> ALTER SYSTEM SET recyclebin = OFF;

Or you are going to change the initialization values within SPFILE or INIT.ORA permanently.

But be aware about  the dropped objects, when recyclebin was ON will remain in the recyclebin even if you set the recyclebin parameter to OFF for your session or the even the whole system.

For freeing this allocated space also, you can use one of the following two commands:

From SCOTT user:
PURGE recyclebin; (Purge all objects in Recyclebin)

From DBA user:
PURGE dba_recyclebin; (Purge all objects / only SYSDBA can)

No comments yet

No comments yet.

Sorry, the comment form is closed at this time.