Alone as an Island What’s the pride in being a Programmer?
Mar 08

From Oracle 10g, Dropped tables can be restored. Meaning, you can now rollback one of your DDL statement. This is how you do it.

drop table t;

Table dropped.

desc t;

ERROR: ORA-04043: object t does not exist

select count(*) from t;

select count(*) from t;

ERROR at line 1: ORA-00942: table or view does not exist

flashback table t to before drop;

Flashback complete.

You have now restored your table.

Behind the scenes, what happens is that your dropped table is renamed and just gets restored from the recyle-bin when you “flashback”.

drop table t;

Table dropped.

select table_name from user_tables;

no rows selected

select object_name from recyclebin;

OBJECT_NAME

——————————

BIN$7oTtcup30ZfgMAGK/3hjKw==

flashback table t to before drop;

Flashback complete.

select object_name from recyclebin;

no rows selected

select table_name from user_tables;

TABLE_NAME

——————————

T

So, your table will not really be dropped. But just like any operating system moved to the recycle-bin from which you can restore later.

If you dont want your tables to be restored and be gone forever, then

drop table t purge;

Table dropped.

select table_name from user_tables;

no rows selected

select object_name from recyclebin;

no rows selected

source: Ask Tom

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis

Tags: , , , ,

No Responses to “Flashback and Purge in Oracle 10g”

  1. Kali Says:

    Arun,
    Seems “flashback” - a miraculous feature in Oracle10g.
    Thanks for “know-how” and EDGE update !!!
    Cant stop my physical/device thinking mind,would it be possible to restore all the files permanently deleted from the HardDrive.Its quite practically possible by a software called”Easy Recovery” which has been my long term dream to think/read/know a lot on more on this.

Leave a Reply

Give your best to the world.