Professional Documents
Culture Documents
After commit user found his made delete operation on wrong table now he
wants to back all deleted records.
2. Ensure that enough undo data exists to rewind the table to the specified
target.
SQL> SELECT NAME, VALUE/60 MINUTES_RETAINED
2 FROM V$PARAMETER
3 WHERE NAME = 'undo_retention';
NAME MINUTES_RETAINED
------------------------------ ----------------
undo_retention 60
3. Ensure that row movement is enabled for all objects that you are
rewinding with Flashback Table.
SQL> alter table SCOTT.EMP enable row movement;
Table altered.
4. Determine whether the table that you intend to flash back has
dependencies on other tables. If dependencies exist, then decide whether to
flash back these tables as well.
SQL> SELECT other.owner, other.table_name
2 FROM sys.all_constraints this, sys.all_constraints other
3 WHERE this.owner = 'SCOTT'
4 AND this.table_name = 'EMP'
5 AND this.r_owner = other.owner
6 AND this.r_constraint_name = other.constraint_name
7 AND this.constraint_type='R';
OWNER TABLE_NAME
------------------------------ ------------------------------
SCOTT DEPT
5. Execute a FLASHBACK TABLE statement for the objects that you want to
flash back.
SQL> flashback table SCOTT.EMP
2 to timestamp to_timestamp ('2008-05-17 18:30:31','YYYY-MM-DD
HH24:MI:SS');
Flashback complete.
For example:
CREATE TABLE t
ENABLE ROW MOVEMENT AS
SELECT owner, table_name, tablespace_name
FROM all_tables
WHERE 1=2;
desc t
INSERT INTO t
SELECT owner, table_name, tablespace_name
FROM all_tables
WHERE owner = 'SYS';
COMMIT;
INSERT INTO t
SELECT owner, table_name, tablespace_name
FROM all_tables
WHERE owner = 'WMSYS';
COMMIT;
INSERT INTO t
SELECT owner, table_name, tablespace_name
FROM all_tables
WHERE owner = 'CTXSYS';
COMMIT;
SQL> create table test tablespace test_restore as select level a1 from dual connect by level <99; Table
created.
2)Note the SCN and Drop the Tablespace with including contents option.
---------------------------------------------------------------------------
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
938686
4)Perform FlashBack.
5)The datafile Become Unnamed. So rename it with original data file location.
6)Now perforem Flashback and Open the database with read only mode.
7)Now you can follow the step 6 choice b)in Peforming Flashback (export) and then recover database.
And later create tablespace and import the contents of tablespace.