GTU MCA MATERIAL FOR DBMS II

RSS
  • Home
  • Quick Review
  • Assignment
  • Backup and Recovery
  • Differences
  • About Me

Saturday, August 13, 2016

SQL Query to recover dropped tables.


Is it possible to recover the dropped tables?

Yes, We can recover the dropped tables using flashback query if it is not permanently deleted.

Whenever you execute any dropped table query, dropped table information are stored in recyclebin. You can execute show recyclebin, it will display objects in recyclebin.

Example

SQL> CREATE TABLE TEST(ID INT);

Table created.

SQL> INSERT INTO TEST VALUES(1001);

1 row created.

SQL> INSERT INTO TEST VALUES(1002);

1 row created.

SQL> INSERT INTO TEST VALUES(1003);

1 row created.

SQL> INSERT INTO TEST VALUES(1004);

1 row created.

SQL> COMMIT;

Commit complete.

SQL> DROP TABLE TEST;

Table dropped.

SQL> SHOW RECYCLEBIN
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST             BIN$Q2h8H7dpTPa/+/wsarPBgA==$0 TABLE        2016-08-13:15:08:34

SQL> FLASHBACK TABLE TEST TO BEFORE DROP;

Flashback complete.

SQL> SELECT * FROM TEST;

        ID
----------
      1001
      1002
      1003
      1004


We can also clear all the object from recyclebin using purge command.

Example

SQL> DROP TABLE TEST;

Table dropped.

SQL> SHOW RECYCLEBIN
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST             BIN$WztpWgD2TOCdtIxsAv+CSw==$0 TABLE        2016-08-13:15:14:53

SQL> PURGE RECYCLEBIN;

Recyclebin purged.


SQL> SHOW RECYCLEBIN

We can also recover dropped table with new name.

Example

SQL> DROP TABLE TEST;

Table dropped.

SQL> SELECT * FROM NEWTEST;
SELECT * FROM NEWTEST
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> FLASHBACK TABLE TEST TO BEFORE DROP
  2     RENAME TO NEWTEST;

Flashback complete.

SQL> SELECT * FROM NEWTEST;

        ID
----------
      1001
      1002
      1003

      1004




Posted by Dr. Parag Shukla at 3:12:00 AM
Email This BlogThis! Share to X Share to Facebook
Labels: flashback, Oracle, purge, recover drop table, rename table.

2 comments:

Chirag Parekh said...

Awesome as always. Appreciate your efforts Sir. Cheers !!

August 13, 2016 at 3:25 AM
Manav Pandya said...

hello sir
Nice share
is this possible to remove all kind of file using Sql ?
Thanks

August 13, 2016 at 3:45 AM

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Total Pageviews

Blog Archive

  • ►  2019 (1)
    • ►  March (1)
  • ▼  2016 (7)
    • ▼  August (6)
      • Difference Between System Level Privileges and Obj...
      • SQL Query to recover dropped tables.
      • SQL query for hierarchical retrieval of employees ...
      • How to Delete duplicate email_ids from table using...
      • SQL Query to perform result analysis of the subjects
      • SQL Query for Grade Calculations
    • ►  July (1)
  • ►  2011 (16)
    • ►  May (2)
    • ►  April (6)
    • ►  March (5)
    • ►  February (3)
  • ►  2010 (9)
    • ►  May (4)
    • ►  March (5)
  • ►  2009 (1)
    • ►  December (1)

Followers

Blog List

Search

Parag Shukla. Powered by Blogger.

Popular Posts

  • Serial Schedule Vs Non-Serial Schedule
    Serial Schedule Non-Serial Schedule A serial schedule is a sequence of operat...
  • Dirty Read Vs Unrepeatable Read
    Dirty Read Unrepeatable Read A dirty read problem occurs when one transaction updates a ...
  • Log Based Recovery
    Log Based Recovery The most widely used structure for recording database modification is the log. The log is a sequence of log ...
  • Lost Update Vs Uncommitted Data
    Lost Update Uncommitted Data This problem is also known as “Multiple Update...
  • Shadow Paging
    Shadow Paging This technique does not require LOG in single user environment In mult...
  • Starvation Vs Deadlock
    Starvation Deadlock Starvation happens if same transaction is always choosen ...
  • Checkpoints
    Checkpoints When System failure occurs o We must consult log to determine those transaction that need to be redone and those tra...
  • Defferred Update method
    Deferred update Do not physically update the database on disk until after a transaction reaches its commit point; Then updates are r...
  • Assignment - 7 Query Processing & Optimization
    Assignment – 7         Query Processing & optimization    Submission Date 30-05-11   Q-1. Explain th...
  • Immediate Update Method
    Immediate update technique Database may be updated by some operations of a transaction before the transaction reaches its commit poi...
Copyright © 2010 GTU MCA MATERIAL FOR DBMS II