Sunday, March 16, 2014

Flashback in table level using system change number (CURRENT_SCN) & BEFORE DROP.

SQL> create table flashback_test(id number(5), name varchar2(30));

Table created.

SQL> SELECT current_scn FROM v$database;

CURRENT_SCN                                                                    
-----------                                                                    
    6249647                                                                    

SQL> insert into flashback_test values(10,'Rajib');

1 row created.

SQL> ALTER TABLE flashback_test ENABLE ROW MOVEMENT;

Table altered.

SQL> insert into flashback_test values(10,'Rajib');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from flashback_test;

        ID NAME                                                                
---------- ------------------------------                                      
        10 Rajib                                                               
        10 Rajib                                                               

SQL>  drop table flashback_test;

Table dropped.

SQL> select * from flashback_test;
select * from flashback_test
              *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> SELECT current_scn FROM v$database;

CURRENT_SCN                                                                    
-----------                                                                    
    6249734                                                                    

SQL> FLASHBACK TABLE flashback_table_test TO SCN 6249647;
FLASHBACK TABLE flashback_table_test TO SCN 6249647
                *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> FLASHBACK TABLE  flashback_test TO BEFORE DROP;

Flashback complete.

SQL> select * from  flashback_test;

        ID NAME                                                                
---------- ------------------------------                                      
        10 Rajib                                                               
        10 Rajib                                                               

SQL>  FLASHBACK TABLE flashback_test TO SCN 6249647;

Flashback complete.

SQL> select * from  flashback_test;

no rows selected

SQL> spool off;

No comments:

Post a Comment