• 不完全恢复用例


    oracle不完全恢复的测试用例
    我们知道oracle的不完全恢复有三种类型:
    基于撤消的恢复
    基于时间的恢复
    基于更改scn的恢复
    以下是基于user和rman两种方式的三种不完全恢复用例:
    测试环境oracle 9.2.0.4+windows xp service pack 2
    一:用 rman方式基于日志序列的不完全恢复
    RMAN> run{
    2> allocate channel c1 type disk;
    3> backup full tag 'dbfull' format 'd:\backup\full%u_%s_%p' database
    4> include current controlfile;
    5> sql 'alter system archive log current';
    6> release channel c1;
    7> }
    sql>alter system switch logfile;
    sql> insert into test values (16);
    commit;
    sql>alter system switch logfile;
    sql> insert into test values (17);
    commit;
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    A
    ----------
    12
    13
    14 --这之前数据是14号日志前产生的
    16 --这之后数据是14号日志后产生的
    17
    16 rows selected.
    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination D:\oracle\ora92\RDBMS
    Oldest online log sequence 14
    Next log sequence to archive 16
    Current log sequence 16
    SQL> alter system switch logfile;
    System altered.
    SQL> select * from v$log;
    GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
    ---------- ---------- ---------- ---------- ---------- --- ----------------
    FIRST_CHANGE# FIRST_TIME
    ------------- -------------------
    1 1 16 104857600 1 YES ACTIVE
    84134 2008-04-10 11:39:19
    2 1 17 104857600 1 NO CURRENT
    84150 2008-04-10 11:40:00
    3 1 15 104857600 1 YES ACTIVE
    84128 2008-04-10 11:39:10
    SQL> exit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    RMAN> shutdown immediate;
    using target database controlfile instead of recovery catalog
    database closed
    database dismounted
    Oracle instance shut down
    RMAN> startup nomount;
    connected to target database (not started)
    Oracle instance started
    Total System Global Area 101785252 bytes
    Fixed Size 454308 bytes
    Variable Size 75497472 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    RMAN> alter database mount;
    database mounted
    RMAN> run{
    2> allocate channel c1 type disk;
    3>set until logseq 14 thread 1; --基于日志序列号的不完全恢复
    4> restore database;
    5> recover database;
    6> sql 'alter database open resetlogs';
    7> }
    allocated channel: c1
    channel c1: sid=11 devtype=DISK
    executing command: SET until clause
    Starting restore at 2008-04-10 11:50:05
    datafile 4 not processed because file is read-only
    channel c1: starting datafile backupset restore
    channel c1: specifying datafile(s) to restore from backup set
    restoring datafile 00001 to D:\ORACLE\ORADATA\PUBTEST\SYSTEM01.DBF
    restoring datafile 00002 to D:\ORACLE\ORADATA\PUBTEST\UNDOTBS01.DBF
    restoring datafile 00003 to D:\ORACLE\ORADATA\PUBTEST\INDX01.DBF
    restoring datafile 00005 to D:\ORACLE\ORADATA\PUBTEST\USERS01.DBF
    channel c1: restored backup piece 1
    piece handle=D:\ORACLE\ORA92\DATABASE\04JDFCP3_1_1
    tag=TAG20080410T113100 params
    =NULL
    channel c1: restore complete
    Finished restore at 2008-04-10 11:50:42
    Starting recover at 2008-04-10 11:50:42
    datafile 4 not processed because file is read-only
    starting media recovery
    archive log thread 1 sequence 9 is already on disk as file D:\ORACLE\ORA92\RDBMS
    \ARC00009.001
    archive log thread 1 sequence 10 is already on disk as file D:\ORACLE\ORA92\RDBM
    S\ARC00010.001
    archive log thread 1 sequence 11 is already on disk as file D:\ORACLE\ORA92\RDBM
    S\ARC00011.001
    archive log thread 1 sequence 12 is already on disk as file D:\ORACLE\ORA92\RDBM
    S\ARC00012.001
    archive log thread 1 sequence 13 is already on disk as file D:\ORACLE\ORA92\RDBM
    S\ARC00013.001
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00009.001 thread=1 sequence=9
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00010.001 thread=1
    sequence=10
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00011.001 thread=1
    sequence=11
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00012.001 thread=1
    sequence=12
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00013.001 thread=1
    sequence=13
    media recovery complete
    Finished recover at 2008-04-10 11:50:43
    sql statement: alter database open resetlogs
    released channel: c1
    RMAN> exit
    Recovery Manager complete.
    C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
    SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 10 11:52:12 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    A
    ----------
    12
    13
    14
    14 rows selected.
    SQL>
    看结果只恢复到14 号日志前的数据
    二:用rman方式基于时间的不完全恢复
    C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
    SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 10 10:28:39 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> create table test (a int);
    Table created.
    SQL> insert into test values(1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> host
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Paul Yi>rman target /
    Recovery Manager: Release 9.2.0.4.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    connected to target database: PUBTEST (DBID=796553641)
    RMAN> run
    2> {allocate channel c1 type disk;
    3> backup full tag 'dbfull' format 'd:\backup\full%U_%s_%p' database
    4> include current controlfile;
    5> sql 'alter system archive log current';
    6> release channel c1;
    7> }
    using target database controlfile instead of recovery catalog
    allocated channel: c1
    channel c1: sid=19 devtype=DISK
    Starting backup at 10-APR-08
    channel c1: starting full datafile backupset
    channel c1: specifying datafile(s) in backupset
    including current SPFILE in backupset
    including current controlfile in backupset
    input datafile fno=00001 name=D:\ORACLE\ORADATA\PUBTEST\SYSTEM01.DBF
    input datafile fno=00004 name=D:\ORACLE\ORADATA\PUBTEST\TOOLS01.DBF
    input datafile fno=00002 name=D:\ORACLE\ORADATA\PUBTEST\UNDOTBS01.DBF
    input datafile fno=00003 name=D:\ORACLE\ORADATA\PUBTEST\INDX01.DBF
    input datafile fno=00005 name=D:\ORACLE\ORADATA\PUBTEST\USERS01.DBF
    channel c1: starting piece 1 at 10-APR-08
    channel c1: finished piece 1 at 10-APR-08
    piece handle=D:\BACKUP\FULL02JDF9CK_1_1_2_1 comment=NONE
    channel c1: backup set complete, elapsed time: 00:00:47
    Finished backup at 10-APR-08
    sql statement: alter system archive log current
    released channel: c1
    RMAN> exit
    Recovery Manager complete.
    C:\Documents and Settings\Paul Yi>exit
    SQL> insert into test values(2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    A
    ----------
    1
    2
    SQL> alter system switch logfile;
    System altered.
    SQL> alter system switch logfile;
    System altered.
    SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    -------------------
    2008-04-10 10:36:14 --恢复基于这个时间点之前的
    SQL> drop table test;
    Table dropped.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area 101785252 bytes
    Fixed Size 454308 bytes
    Variable Size 75497472 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    SQL> exit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    RMAN> exit
    Recovery Manager complete.
    C:\Documents and Settings\Paul Yi>set nls_date_format=yyyy-mm-dd hh24:mi:ss
    C:\Documents and Settings\Paul Yi>rman target /
    Recovery Manager: Release 9.2.0.4.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    connected to target database: PUBTEST (DBID=796553641)
    RMAN> run{
    2> allocate channel c1 type disk;
    3> restore database;
    4> recover database until time '2008-04-10 10:36:14'; --基于这个时间点之前的不完
    全恢复
    5> sql 'alter database open resetlogs';
    6> release channel c1;
    7> }
    using target database controlfile instead of recovery catalog
    allocated channel: c1
    channel c1: sid=9 devtype=DISK
    Starting restore at 2008-04-10 10:44:30
    datafile 4 not processed because file is read-only
    skipping datafile 1; already restored to file D:\ORACLE\ORADATA\PUBTEST\SYSTEM0
    .DBF
    skipping datafile 2; already restored to file D:\ORACLE\ORADATA\PUBTEST\UNDOTBS
    1.DBF
    skipping datafile 3; already restored to file D:\ORACLE\ORADATA\PUBTEST\INDX01.
    BF
    skipping datafile 5; already restored to file D:\ORACLE\ORADATA\PUBTEST\USERS01
    DBF
    restore not done; all files readonly, offline, or already restored
    Finished restore at 2008-04-10 10:44:30
    Starting recover at 2008-04-10 10:44:30
    datafile 4 not processed because file is read-only
    starting media recovery
    archive log thread 1 sequence 2 is already on disk as file D:\ORACLE\ORA92\RDBM
    \ARC00002.001
    archive log thread 1 sequence 3 is already on disk as file D:\ORACLE\ORA92\RDBM
    \ARC00003.001
    archive log thread 1 sequence 4 is already on disk as file D:\ORACLE\ORA92\RDBM
    \ARC00004.001
    archive log filename=D:\ORACLE\ORA92\RDBMS\ARC00002.001 thread=1 sequence=2
    media recovery complete
    Finished recover at 2008-04-10 10:44:32
    sql statement: alter database open resetlogs
    released channel: c1
    RMAN> exit
    Recovery Manager complete.
    C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
    SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 10 10:44:52 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> select * from test;
    A
    ----------
    1
    2
    至此恢复完成到没有drop 表之前的状态
    三:用rman方式基于scn的不完全恢复
    SQL> create table test(a int);
    Table created.
    SQL> insert into test values(1);
    1 row created.
    SQL> commit;
    Commit complete.
    C ocuments and SettingsPaul Yi>rman target /
    Recovery Manager: Release 9.2.0.4.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    connected to target database: PUBTEST (DBID=792660220)
    RMAN> run{allocate channel c1 type disk;
    2> backup full tag 'dbfull' format 'd: ackupfull%u_%s_%p' database
    3> include current controlfile;
    4> sql 'alter system archive log current';
    5> release channel c1;
    6> }
    using target database controlfile instead of recovery catalog
    allocated channel: c1
    channel c1: sid=12 devtype=DISK
    Starting backup at 08-APR-08
    channel c1: starting full datafile backupset
    channel c1: specifying datafile(s) in backupset
    including current SPFILE in backupset
    including current controlfile in backupset
    input datafile fno=00001 name=D:ORACLEORADATAPUBTESTSYSTEM01.DBF
    input datafile fno=00002 name=D:ORACLEORADATAPUBTESTUNDOTBS01.DBF
    input datafile fno=00003 name=D:ORACLEORADATAPUBTESTINDX01.DBF
    input datafile fno=00005 name=D:ORACLEORADATAPUBTESTUSERS01.DBF
    channel c1: starting piece 1 at 08-APR-08
    channel c1: finished piece 1 at 08-APR-08
    piece handle=D:BACKUPFULL01JDAN3K_1_1 comment=NONE
    channel c1: backup set complete, elapsed time: 00:01:59
    Finished backup at 08-APR-08
    sql statement: alter system archive log current
    released channel: c1
    RMAN> exit
    Recovery Manager complete.
    Cocuments and SettingsPaul Yi>sqlplus "/as sysdba"
    SQL*Plus: Release 9.2.0.4.0 - Production on Tue Apr 8 16:59:38 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> insert into test values(2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    A
    ----------
    1
    2
    SQL> alter system switch logfile;
    System altered.
    SQL> alter system switch logfile;
    System altered.
    SQL> select max(ktuxescnw * power(2, 32) + ktuxescnb) scn from x$ktuxe;
    SCN
    ----------
    1195547
    SQL> drop table test;
    Table dropped.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area 546382300 bytes
    Fixed Size 455132 bytes
    Variable Size 520093696 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    SQL> exit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    Cocuments and SettingsPaul Yi>rman target /
    Recovery Manager: Release 9.2.0.4.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    connected to target database: PUBTEST (DBID=792660220)
    RMAN> run{
    2> allocate channel c1 type disk;
    3> restore database;
    4>recover database until scn 1195547;
    5> sql 'alter database open resetlogs';
    6> release channel c1;
    7> }
    using target database controlfile instead of recovery catalog
    allocated channel: c1
    channel c1: sid=11 devtype=DISK
    Starting restore at 08-APR-08
    datafile 3 not processed because file is read-only
    channel c1: starting datafile backupset restore
    channel c1: specifying datafile(s) to restore from backup set
    restoring datafile 00001 to D:ORACLEORADATAPUBTESTSYSTEM01.DBF
    restoring datafile 00002 to D:ORACLEORADATAPUBTESTUNDOTBS01.DBF
    restoring datafile 00005 to D:ORACLEORADATAPUBTESTUSERS01.DBF
    channel c1: restored backup piece 1
    piece handle=D:BACKUPFULL01JDAN3K_1_1 tag=DBFULL params=NULL
    channel c1: restore complete
    Finished restore at 08-APR-08
    Starting recover at 08-APR-08
    datafile 3 not processed because file is read-only
    starting media recovery
    archive log thread 1 sequence 1 is already on disk as file D:ORACLEORA92RDBMS
    ARC00001.001
    archive log thread 1 sequence 2 is already on disk as file D:ORACLEORA92RDBMS
    ARC00002.001
    archive log filename=D:ORACLEORA92RDBMSARC00001.001 thread=1
    sequence=1
    media recovery complete
    Finished recover at 08-APR-08
    sql statement: alter database open resetlogs
    released channel: c1
    RMAN> exit
    Recovery Manager complete.
    Cocuments and SettingsPaul Yi>sqlplus "/as sysdba"
    SQL*Plus: Release 9.2.0.4.0 - Production on Tue Apr 8 17:05:03 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> select * from test;
    A
    ----------
    1
    2
    四:用user模式基于日志序列的不完全恢复
    sql>shutdown immediate;
    冷备数据库所有数据文件
    SQL> startup
    ORACLE instance started.
    Total System Global Area 101785252 bytes
    Fixed Size 454308 bytes
    Variable Size 75497472 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    Database opened.
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination D:\oracle\ora92\RDBMS
    Oldest online log sequence 0
    Next log sequence to archive 1
    Current log sequence 1
    SQL> alter system switch logfile;
    System altered.
    SQL> insert into test values(5);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter system switch logfile;
    System altered.
    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination D:\oracle\ora92\RDBMS
    Oldest online log sequence 1
    Next log sequence to archive 3
    Current log sequence 3
    SQL> insert into test values(6);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    5
    6
    6 rows selected.
    SQL> alter system switch logfile;
    System altered.
    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination D:\oracle\ora92\RDBMS
    Oldest online log sequence 2
    Next log sequence to archive 4
    Current log sequence 4
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    5
    6
    6 rows selected.
    SQL> insert into test values(7); --7这个值用到的日志序列为4
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter system switch logfile;
    System altered.
    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination D:\oracle\ora92\RDBMS
    Oldest online log sequence 3
    Next log sequence to archive 5
    Current log sequence 5
    SQL> insert into test values(8); --8这个值用到的日志序列为5
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter system switch logfile;
    System altered.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    恢复所有冷备的数据文件
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area 101785252 bytes
    Fixed Size 454308 bytes
    Variable Size 75497472 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    做不完全恢复到日志序列为4
    SQL> recover database until cancel;
    ORA-00279: change 270609 generated at 04/21/2008 10:22:02 needed for thread 1
    ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00001.001
    ORA-00280: change 270609 for thread 1 is in sequence #1
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    D:\oracle\ora92\rdbms\ARC00001.001
    ORA-00279: change 270822 generated at 04/21/2008 10:28:29 needed for thread 1
    ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00002.001
    ORA-00280: change 270822 for thread 1 is in sequence #2
    ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00001.001' no longer needed for
    this recovery
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    D:\oracle\ora92\rdbms\ARC00002.001
    ORA-00279: change 270856 generated at 04/21/2008 10:30:06 needed for thread 1
    ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00003.001
    ORA-00280: change 270856 for thread 1 is in sequence #3
    ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00002.001' no longer needed for
    this recovery
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    D:\oracle\ora92\rdbms\ARC00003.001
    ORA-00279: change 270869 generated at 04/21/2008 10:30:37 needed for thread 1
    ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00004.001
    ORA-00280: change 270869 for thread 1 is in sequence #4
    ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00003.001' no longer needed for
    this recovery
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    D:\oracle\ora92\rdbms\ARC00004.001
    ORA-00279: change 270918 generated at 04/21/2008 10:33:01 needed for thread 1
    ORA-00289: suggestion : D:\ORACLE\ORA92\RDBMS\ARC00005.001
    ORA-00280: change 270918 for thread 1 is in sequence #5
    ORA-00278: log file 'D:\oracle\ora92\rdbms\ARC00004.001' no longer needed for
    this recovery
    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    cancel --ARC00005.001 这个撤消不恢复了
    Media recovery cancelled.
    SQL> alter database open resetlogs;
    Database altered.
    SQL> select * from test;
    A
    ----------
    1
    2
    3
    4
    5
    6
    7
    7 rows selected.
    SQL>
    看结果只恢复到日志序列4对应的test 表数据为7
    五:用user_command方式基于时间的不完全恢复
    SQL> select * from test;
    ID
    ----------
    1
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    这时备份所有数据文件
    SQL> startup
    ORACLE instance started.
    Total System Global Area 546382300 bytes
    Fixed Size 455132 bytes
    Variable Size 520093696 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    Database opened.
    SQL> insert into test values(2);
    1 row created.
    SQL> commit;
    Commit complete.
    Sql> select * from test
    1
    2
    SQL> select sysdate from dual;
    SYSDATE
    ---------
    09-APR-08
    SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi;ss';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    -------------------
    2008-04-09 09:44;37 --基于这个时间点之前的
    SQL> drop table test;
    Table dropped.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    把备份的所有数据文件拷贝回来
    SQL> startup mount;
    ORACLE instance started.
    Total System Global Area 546382300 bytes
    Fixed Size 455132 bytes
    Variable Size 520093696 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    SQL>recover database until time '2008-04-09 09:44:37'; 做基于时间的不完全恢复
    Media recovery complete.
    SQL> alter database open resetlogs;
    Database altered.
    SQL> select * from test;
    ID
    ----------
    1
    2
    六:用user_command方式基于scn的不完全恢复
    SQL> select * from test;
    ID
    ----------
    1
    2
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    备份cp 所有数据文件
    SQL> startup
    ORACLE instance started.
    Total System Global Area 546382300 bytes
    Fixed Size 455132 bytes
    Variable Size 520093696 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    Database opened.
    SQL> insert into test values(3);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test;
    ID
    ----------
    1
    2
    3
    SQL> select dbms_flashback.get_system_change_number from dual; --查出scn号
    GET_SYSTEM_CHANGE_NUMBER
    ------------------------
    1219138
    SQL> drop table test;
    Table dropped.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    恢复备份的所有数据文件
    SQL> startup mount
    ORACLE instance started.
    Total System Global Area 546382300 bytes
    Fixed Size 455132 bytes
    Variable Size 520093696 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 667648 bytes
    Database mounted.
    SQL>recover database until change 1219138; --基于scn的不完全恢复
    Media recovery complete.
    SQL> alter database open resetlogs;
    Database altered.
    SQL> select * from test;
    ID
    ----------
    1
    2
    3

  • 相关阅读:
    android用户界面对话框
    JSP+JAVABEAN+SERVLET模式的注册实例实现
    android用户界面组件Widget网络视图WebView
    android广播事件处理broadcast receive
    android用户界面组件Widget地图视图MapView
    android用户界面组件Widget画廊视图Gallery
    android用户界面组件Widget网格视图GridView
    Windows Phone 7 hello world
    Android组件的通讯Intent
    android的互联网开发
  • 原文地址:https://www.cnblogs.com/datalife/p/1985449.html
Copyright © 2020-2023  润新知