Saturday, April 12, 2008

use RMAN to flashback database to time;

14:31:17 SQL> prompt NOW test flashback to time;
NOW test flashback to time
14:31:59 SQL> select * from hr.test_table1;

no rows selected

14:32:10 SQL> insert into hr.test_table1 values(100);

1 row created.

14:32:25 SQL> commit;

Commit complete.

14:32:30 SQL> select * from hr.test_table1;

F1
----------
100

14:32:33 SQL> drop table hr.test_table1;

Table dropped.

14:32:48 SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
14:33:09 SQL> startup mount;
ORACLE instance started.

Total System Global Area 1035993088 bytes
Fixed Size 2077904 bytes
Variable Size 624954160 bytes
Database Buffers 402653184 bytes
Redo Buffers 6307840 bytes
Database mounted.
14:33:25 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
[oracle*OCP10G@localhost ~]$rman

Recovery Manager: Release 10.2.0.3.0 - Production on Sat Apr 12 14:33:29 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

RMAN> connect target

connected to target database: OCP10G (DBID=3491152056, not open)

RMAN> flashback database to time="to_date('04/12/2008 14:32:30','mm/dd/yyyy hh24:mi:ss')";

Starting flashback at 12-APR-08
using channel ORA_DISK_1


starting media recovery
media recovery complete, elapsed time: 00:00:07

Finished flashback at 12-APR-08

RMAN> exit


Recovery Manager complete.
[oracle*OCP10G@localhost ~]$sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Sat Apr 12 14:42:14 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> alter database open resetlogs;

Database altered.

SQL> select * from hr.test_table1;

F1
----------
100