Popular Posts

Thursday, 22 August 2013

GET DROPED TABLE BACK VIA FLASHBACK

1.DROP TABLE COMMAND/PURGE RECYCEBIN


 Get droped table BACK VIA FLASHBACK

The Oracle DROP command is used to remove database objects (tables, functions, views, profiles, etc) from the database. It does this by deleting the object definition and any associated references.

When a table is dropped, all the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. 

As of Oracle 10g, when a table is dropped it is moved into the recycle bin unless the PURGE modifier is used. If the PURGE modifier is used then the table is dropped completely from the database and is unrecoverable. 

The DROP command may also be used to remove a database link.
FOR EXAMPLE:
DROP TEST  (WHERE TEST IS THE TABLE)
DROP PROFILE developer( a profile been droped)
DROP VIEW testview( clearly this is view been droped)
DROP PUBLIC DATABASE LINK remote (specify PUBLIC TO DROP PUBLIC LINKS,cannot be droped if present in another user schema)
 
 
...................................................................
 Ohhh Accedentaly i have droped my favorate table now waht to do??????????
 
 
FLASHBACK  (not FLASH GORDON.....) TO RESCUE.............

Oracle Flashback Drop reverses the effects of a DROP TABLE operation. It can be used to recover after the accidental drop of a table. Flashback Drop is substantially faster than other recovery mechanisms that can be used in this situation, such as point-in-time recovery, and does not lead to any loss of recent transactions or downtime.
When you drop a table, the database does not immediately remove the space associated with the table. Instead, the table is renamed and, along with any associated objects, it is placed in the Recycle Bin of the database. The Flashback Drop operation recovers the table from the recycle bin.
FOR EXAMPLE:

SQL>DROP TABLE Test_demo PURGE;
Table Dropped
 
The table and its dependent objects will remain in the recycle bin until they are purged from the recycle bin         
To view the contents of the recycle bin, use the SQL*Plus command SHOW RECYCLEBIN.
SQL> show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                   TYPE         DROP TIME
---------------- --------------------------------- ------------ -------------------
TEST_DEMO    BIN$gk3lsj/3akk5hg3j2lkl5j3d==$0      TABLE        2013-08-20:17:08:54

NOW LETS REGAIN BACK OUR TABLE::::

 To use the FLASHBACK TABLE ... TO BEFORE DROP statement, you need the same privileges you need to drop the table.SO HERE ARE THE MAGIC WORDS-------------

FLASHBACK TABLE TEST_DEMO TO BEFORE DROP;
 

The most recently dropped table with that original name is retrieved from the recycle bin, with its original name. You can retrieve it and assign it a new name using a RENAME TO clause....HOW  lets SEE....

FLASHBACK TABLE TEST_DEMO TO BEFORE DROP RENAME TO TEST_DEMO_1;



Purging Objects from the Recycle Bin:
1.USING TABLE NAME:
PURGE TABLE TEST_DEMO;
2.  recycle bin name of an object:
PURGE TABLE " BIN$gk3lsj/3akk5hg3j2lkl5j3d==$0";
(REMEMBER THE ABOVE QUERY WHERE WE GOT THE INFO FROM RECYCLE BIN;

3. PURGE INDEX: Freeing Space in the Recycle Bin

               PURGE INDEX "BIN$GTE72KJ22H9==$0";

4. PURGE RECYCLEBIN: Purging All Objects in a User's Recycle Bin

PURGE DBA_RECYCLEBIN;

OK its DONE.....FOR MORE INFO GO DO GOOGLE(..JUST KIDDING MAN!!!!!) .OH WAIT ARE ALL TABLE BEEN DROPED ARE POSSIBLE TO GET BACK...IT DEPENDS!!!!!LET SEE ON WHAT

Limitations and Restrictions on Flashback Drop(SIMPLE FROM ORACLE DOC)
  • The recycle bin functionality is only available for non-system, locally managed tablespaces. If a table is in a non-system, locally managed tablespace, but one or more of its dependent segments (objects) is in a dictionary-managed tablespace, then these objects are protected by the recycle bin.
  • There is no fixed amount of space allocated to the recycle bin, and no guarantee as to how long dropped objects remain in the recycle bin. Depending upon system activity, a dropped object may remain in the recycle bin for seconds, or for months.
  • While Oracle permits queries against objects stored in the recycle bin, you cannot use DML or DDL statements on objects in the recycle bin.
  • You can perform Flashback Query on tables in the recycle bin, but only by using the recycle bin name. You cannot use the original name of the table.
  • A table and all of its dependent objects (indexes, LOB segments, nested tables, triggers, constraints and so on) go into the recycle bin together, when you drop the table. Likewise, when you perform Flashback Drop, the objects are generally all retrieved together.
It is possible, however, that some dependent objects such as indexes may have been reclaimed due to space pressure. In such cases, the reclaimed dependent objects are not retrieved from the recycle bin.
  • Due to security concerns, tables which have Fine-Grained Auditing (FGA) and Virtual Private Database (VPD) policies defined over them are not protected by the recycle bin.
  • Partitioned index-organized tables are not protected by the recycle bin.
  • The recycle bin does not preserve referential constraints on a table (though other constraints will be preserved if possible). If a table had referential constraints before it was dropped (that is, placed in the recycle bin), then re-create any referential constraints after you retrieve the table from the recycle bin with Flashback Drop.


No comments :

Post a Comment