Sunday, July 26, 2009

Recyclebin in Oracle 10g

The recyclebin concept is introduced in oracle 10g onwards . So far we have been knowing that the DDL commands are auto commited and cannot be recovered as a normal user. But the oracle 10g onwards the recyclebin is introduced like we have in windows.
The user_recyclebin and dba_recyclebin data dictionaries can be used to view the deleted contents. Let's see the following example to understand this concept.
SQL> create table test
( id number,
name varchar2(30));

SQL> insert into test values ( 1,'name1');

SQL> select *
from test;

ID NAME
------------------
1 name1

Let's drop the table

SQL> drop table test;

Now this table goes into the recyclebin. (Here recyclebin is a synonym for user_recyclebin )

SQL> select *
from recyclebin;

OBJECT_NAME ORIGINAL_NAME DROP_TIME
----------------------------------------------------------
BIN$b5sG6wgurG3gQAnAoNwPOA==$0 TEST 2009-07-26:16:50:38

If you want to get back(restore) then

SQL> flashback table test to before drop;          

Now you can view the test table.

If you want to drop the table permenantly without going to the recyclebin then issue

SQL> drop table test purge;        

No comments:

Post a Comment