SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How To Recover a Dropped Table?

Go down

How To Recover a Dropped Table? Empty How To Recover a Dropped Table?

Post by Micheal Tue Jan 19, 2010 7:24 am

If you accidentally dropped a table, can you recover it back? The answer is yes, if you have the
recycle bin feature turned on. You can use the FLASHBACK TABLE ... TO BEFORE DROP
statement to recover a dropped table from the recycle bin as shown in the following SQL script:
SQL> CREATE TABLE emp_dept_90
2 AS SELECT * FROM employees WHERE department_id=90;
Table created.
SQL> SELECT COUNT(*) FROM emp_dept_90;
COUNT(*)
----------
3
SQL> DROP TABLE emp_dept_90;
Table dropped.
SQL> FLASHBACK TABLE emp_dept_90 TO BEFORE DROP RENAME TO emp_dept_bck;
Flashback complete.
SQL> SELECT COUNT(*) FROM emp_dept_bck;
COUNT(*)
----------
3
The FLASHBASK statement in this script recovered the dropped table "emp_dept_90" to new
name "emp_dept_bck". All the data rows are recovered nicely.

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum