Oracle基于用户管理的不完全恢复

来源:互联网 发布:在日本护肤品档次 知乎 编辑:程序博客网 时间:2024/05/22 14:50

基于SCN

[oracle@zwc ~]$ sqlplus /nologSQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 09:54:25 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.SQL> conn zhongwcEnter password: Connected.SQL> create table t_rec(id number(2) primary key,name varchar2(10));Table created.SQL> insert into t_rec values (1,'aaa');1 row created.SQL> insert into t_rec values (2,'bbb');1 row created.SQL> commit;Commit complete.SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbbSQL> select current_scn from v$database;CURRENT_SCN-----------    3401445SQL> select current_scn from v$database;CURRENT_SCN-----------    3401447SQL> @clod_backupSP2-0310: unable to open file "clod_backup.sql"SQL> @/u01/backup/clod_backupSQL> show userUSER is "SYS"SQL> conn zhongwcEnter password: Connected.SQL> select * from t_rec;ID NAME                                                                                                                                                                                                                                                                                             ---------- ----------                                                                                                                                                                                                                                                                                        1 aaa                                                                                                                                                                                                                                                                                               2 bbb                                                                                                                                                                                                                                                                                              2 rows selected.SQL> truncate table t_rec;Table truncated.SQL> select * from t_rec;no rows selectedSQL> conn / as sysdbaConnected.SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> !cp /u01/backup/*.dbf /u01/app/oracle/oradata/ZWCSQL> startup mountORACLE instance started.Total System Global Area 1653518336 bytes                                                                                                                                                                                                                                                                   Fixed Size    2228904 bytes                                                                                                                                                                                                                                                                   Variable Size 1140854104 bytes                                                                                                                                                                                                                                                                   Database Buffers  503316480 bytes                                                                                                                                                                                                                                                                   Redo Buffers    7118848 bytes                                                                                                                                                                                                                                                                   Database mounted.SQL> recover database until change 3401445;Media recovery complete.SQL> alter database open resetlogs;Database altered.SQL> conn zhongwcEnter password: Connected.SQL> select * from t_rec;ID NAME                                                                                                                                                                                                                                                                                             ---------- ----------                                                                                                                                                                                                                                                                                    1 aaa                                                                                                                                                                                                                                                                                               2 bbb                                                                                                                                                                                                                                                                                              2 rows selected.

基于log seq

[oracle@zwc ~]$ sqlplus zhongwc/zhongwcSQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:12:00 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show userUSER is "ZHONGWC"SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbbSQL> @/u01/backup/clod_backupSQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@zwc ~]$ sqlplus zhongwc/zhongwcSQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:13:50 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> archive log listORA-01031: insufficient privilegesSQL> conn / as sysdbaConnected.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     1Next log sequence to archive   2Current log sequence       2SQL> insert into zhongwc.t_rec values(3,'ccc');1 row created.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     1Next log sequence to archive   2Current log sequence       2SQL> alter system switch logfile;System altered.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     1Next log sequence to archive   3Current log sequence       3SQL> insert into zhongwc.t_rec values(4,'ddd');1 row created.SQL> commit;Commit complete.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     1Next log sequence to archive   3Current log sequence       3SQL> alter system switch logfile;System altered.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     2Next log sequence to archive   4Current log sequence       4SQL> insert into zhongwc.t_rec values(5,'eee');1 row created.SQL> commit;Commit complete.SQL> alter system switch logfile;System altered.SQL> archive log listDatabase log mode       Archive ModeAutomatic archival       EnabledArchive destination       /u01/app/oracle/oradata/ZWC/archOldest online log sequence     3Next log sequence to archive   5Current log sequence       5SQL> conn zhongwc/zhongwcConnected.SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 ddd 5 eeeSQL> truncate table t_rec;Table truncated.SQL> select * from t_rec;no rows selectedSQL> conn / as sysdbaConnected.SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> !cp /u01/backup/*.dbf /u01/app/oracle/oradata/ZWCSQL> startup mountORACLE instance started.Total System Global Area 1653518336 bytesFixed Size    2228904 bytesVariable Size 1140854104 bytesDatabase Buffers  503316480 bytesRedo Buffers    7118848 bytesDatabase mounted.SQL> recover database until cancel;ORA-00279: change 3402600 generated at 02/05/2013 10:12:34 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/oradata/ZWC/arch/1_2_806580022.dbfORA-00280: change 3402600 for thread 1 is in sequence #2Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/u01/app/oracle/oradata/ZWC/arch/1_2_806580022.dbfORA-00279: change 3402892 generated at 02/05/2013 10:14:40 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/oradata/ZWC/arch/1_3_806580022.dbfORA-00280: change 3402892 for thread 1 is in sequence #3ORA-00278: log file '/u01/app/oracle/oradata/ZWC/arch/1_2_806580022.dbf' nolonger needed for this recoverySpecify log: {<RET>=suggested | filename | AUTO | CANCEL}/u01/app/oracle/oradata/ZWC/arch/1_3_806580022.dbfORA-00279: change 3402904 generated at 02/05/2013 10:15:10 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/oradata/ZWC/arch/1_4_806580022.dbfORA-00280: change 3402904 for thread 1 is in sequence #4ORA-00278: log file '/u01/app/oracle/oradata/ZWC/arch/1_3_806580022.dbf' nolonger needed for this recoverySpecify log: {<RET>=suggested | filename | AUTO | CANCEL}cancelMedia recovery cancelled.SQL> alter database open resetlogs;Database altered.SQL> conn zhongwc/zhongwcConnected.SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 ddd

基于time

[oracle@zwc ~]$ sqlplus zhongwc/zhongwcSQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:26:44 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show userUSER is "ZHONGWC"SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 dddSQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';Session altered.SQL> select sysdate from dual;SYSDATE-------------------2013-02-05 10:27:44SQL> select sysdate from dual;SYSDATE-------------------2013-02-05 10:27:46SQL> @/u01/backup/clod_backupSQL> show userUSER is "SYS"SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@zwc ~]$ sqlplus zhongwc/zhongwcSQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 5 10:29:20 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 dddSQL> insert into t_rec values(10,'zwc');1 row created.SQL> commit;Commit complete.SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 ddd10 zwcSQL> truncate table t_rec;Table truncated.SQL> select * from t_rec;no rows selectedSQL> show userUSER is "ZHONGWC"SQL> conn / as sysdbaConnected.SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> !cp /u01/backup/*.dbf /u01/app/oracle/oradata/ZWCSQL> startup mountORACLE instance started.Total System Global Area 1653518336 bytesFixed Size    2228904 bytesVariable Size 1140854104 bytesDatabase Buffers  503316480 bytesRedo Buffers    7118848 bytesDatabase mounted.SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';Session altered.SQL> recover database until time ORA-00285: TIME not given as a string constantSQL> recover database until time '2013-02-05 10:27:44';Media recovery complete.SQL> alter database open resetlogs;Database altered.SQL> conn zhongwc/zhongwcConnected.SQL> select * from t_rec;ID NAME---------- ---------- 1 aaa 2 bbb 3 ccc 4 ddd



原创粉丝点击