How to recover a dropped table in Oracle 11g when flashback mode is off
After dropping table and before restoring it from the recycle bin, run the following query:
Login with table owner schema.
SQL > SELECT OBJECT_NAME, ORIGINAL_NAME, TYPE FROM RECYCLEBIN;
if table is there than use below statement to restore.
Restore the table with the following command:
SQL > FLASHBACK TABLE drop_table_NAME TO BEFORE DROP;
Recovering dropped table is easy in Oracle, provided that the table was not dropped with PURGE option. In case the table is dropped and space occupied by the table is released and the table does not get moved into the recycle bin. But if table is dropped without PURGE option, Oracle has this very neat feature - Recycle bin, similar to the recycle bin in Windows. There are two recyle bin views in Oracle: USER_RECYCLEBIN and DBA_RECYCLEBIN, Synonym RECYCLEBIN points to your USER_RECYCLEBIN.
The recycle bin can be turned on and off with RECYCLEBIN initialization parameter. When table is dropped, it get rename to system-generated name preceeded with BIN and stored in recycle bin. The important thing to know is that after table has been dropped, it's only been renamed, the table segmants are still in the tablespace, unchanged. the space occupied by the table will not be reclaimed until the table has been purged from the recycle bin.
While in the recycle bin, the table can even be queried using the newly generated name that starts qwith BIN$.
The table can easily be recovered from the recycle bin using flashback drop, which will rename the table to its original name.
You can check flashback mode by running
SELECT FLASHBACK_ON FROM V$DATABASE;
First check the parameter Recyclebin is set to true. Recycle bin is a data dictionary table that contains information about dropped objects. Dropped tables and any associated objects such as indexes, constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints.
SHOW PARAMETER RECYCLEBIN;
if recyclebin is set to off, perform the following steps:
ALTER SYSTEM SET RECYCLEBIN=ON SCOPE=SPFILE;
verify that recyclebin parameter is now set to ON
shutdown the database
SHUTDOWN IMMEDIATE
Restart the database
STARTUP
then run
SELECT * FROM RECYCLEBIN;
and see if your table is in there. If it is, use the following quesry to restore it:
FLASHBACK TABLE TO BEFORE DROP;
Then check if the table is back:
SELECT * FROM USER_TABLES WHERE TABLE_NAME=;
**********************************************************
SQL > SELECT * FROM RECYCLEBIN;
SQL > SELECT object_name, original_name FROM dba_recyclebin WHERE owner = 'Schema_name';
SQL > SELECT object_name, original_name, createtime FROM recyclebin;
SQL > desc dba_recyclebin;
SQL > select OWNER,OBJECT_NAME,ORIGINAL_NAME,CREATETIME,DROPTIME from dba_recyclebin WHERE owner = 'Schema_name';
Login with drop table owner schema
SQL > show user;
HR
SQL > FLASHBACK TABLE DROP_TABLE_NAME TO BEFORE DROP;
Clear Recyclebin
To remove all dropped objects from the recyclebin (current user):
PURGE RECYCLEBIN;
To remove all dropped objects from the recyclebin (system wide, available to SYSDBA only or, starting with version 12c, to users having the PURGE DBA_RECYCLEBIN system privilege):
PURGE DBA_RECYCLEBIN;
Tables can also be dropped without sending them to the recyclebin. Example:
DROP TABLE tba PURGE;
Tables inside recycle bin can be purged individually. Example:
PURGE TABLE tba;
Drop a table:
SQL> DROP TABLE tba;
Undrop the table:
SQL> FLASHBACK TABLE tba TO BEFORE DROP;
After dropping table and before restoring it from the recycle bin, run the following query:
Login with table owner schema.
SQL > SELECT OBJECT_NAME, ORIGINAL_NAME, TYPE FROM RECYCLEBIN;
if table is there than use below statement to restore.
Restore the table with the following command:
SQL > FLASHBACK TABLE drop_table_NAME TO BEFORE DROP;
Recovering dropped table is easy in Oracle, provided that the table was not dropped with PURGE option. In case the table is dropped and space occupied by the table is released and the table does not get moved into the recycle bin. But if table is dropped without PURGE option, Oracle has this very neat feature - Recycle bin, similar to the recycle bin in Windows. There are two recyle bin views in Oracle: USER_RECYCLEBIN and DBA_RECYCLEBIN, Synonym RECYCLEBIN points to your USER_RECYCLEBIN.
The recycle bin can be turned on and off with RECYCLEBIN initialization parameter. When table is dropped, it get rename to system-generated name preceeded with BIN and stored in recycle bin. The important thing to know is that after table has been dropped, it's only been renamed, the table segmants are still in the tablespace, unchanged. the space occupied by the table will not be reclaimed until the table has been purged from the recycle bin.
While in the recycle bin, the table can even be queried using the newly generated name that starts qwith BIN$.
The table can easily be recovered from the recycle bin using flashback drop, which will rename the table to its original name.
You can check flashback mode by running
SELECT FLASHBACK_ON FROM V$DATABASE;
First check the parameter Recyclebin is set to true. Recycle bin is a data dictionary table that contains information about dropped objects. Dropped tables and any associated objects such as indexes, constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints.
SHOW PARAMETER RECYCLEBIN;
if recyclebin is set to off, perform the following steps:
ALTER SYSTEM SET RECYCLEBIN=ON SCOPE=SPFILE;
verify that recyclebin parameter is now set to ON
shutdown the database
SHUTDOWN IMMEDIATE
Restart the database
STARTUP
then run
SELECT * FROM RECYCLEBIN;
and see if your table is in there. If it is, use the following quesry to restore it:
FLASHBACK TABLE TO BEFORE DROP;
Then check if the table is back:
SELECT * FROM USER_TABLES WHERE TABLE_NAME=;
**********************************************************
SQL > SELECT * FROM RECYCLEBIN;
SQL > SELECT object_name, original_name FROM dba_recyclebin WHERE owner = 'Schema_name';
SQL > SELECT object_name, original_name, createtime FROM recyclebin;
SQL > desc dba_recyclebin;
SQL > select OWNER,OBJECT_NAME,ORIGINAL_NAME,CREATETIME,DROPTIME from dba_recyclebin WHERE owner = 'Schema_name';
Login with drop table owner schema
SQL > show user;
HR
SQL > FLASHBACK TABLE DROP_TABLE_NAME TO BEFORE DROP;
Clear Recyclebin
To remove all dropped objects from the recyclebin (current user):
PURGE RECYCLEBIN;
To remove all dropped objects from the recyclebin (system wide, available to SYSDBA only or, starting with version 12c, to users having the PURGE DBA_RECYCLEBIN system privilege):
PURGE DBA_RECYCLEBIN;
Tables can also be dropped without sending them to the recyclebin. Example:
DROP TABLE tba PURGE;
Tables inside recycle bin can be purged individually. Example:
PURGE TABLE tba;
Drop a table:
SQL> DROP TABLE tba;
Undrop the table:
SQL> FLASHBACK TABLE tba TO BEFORE DROP;