今天在测试环境本来想模拟一个数据块讹误的错误,但是在实际的操作中却碰到了另外一个问题。 修改完数据文件后,启动数据库碰到ora-1122的错误,没办法只能做数据恢复了,幸亏我在在实验之前冷备整个数据文件。 以下是我的操作步骤:
SQL> select name from v$datafile;
NAME
-------------------------------------------------------------------------------- /app/oracle/oradata/gbk/system01.dbf /app/oracle/oradata/gbk/undotbs01.dbf /app/oracle/oradata/gbk/sysaux01.dbf /app/oracle/oradata/gbk/users01.dbfSQL>
SQL> create tablespace block
2 datafile '/app/oracle/oradata/gbk/block.dbf' 3 size 100M 4 extent management local;SQL> alter user wwx identified by 'password' default tablespace block;
SQL>grant resource,create session to wwx;
SQL> create table test as select * from all_users;
Table created.
SQL> insert into test select * from test;
23 rows created.
SQL> /
46 rows created.
。。。。。。
SQL> /
2944 rows created.
SQL> select count(*) from test;
COUNT(*)
---------- 5888SQL> show user
USER is "WWX" SQL> conn /as sysdba Connected. SQL> alter system switch logfile;System altered.
SQL> shutdown immediate
Database closed. Database dismounted. ORACLE instance shut down.SQL> host cp /app/oracle/oradata/gbk/block.dbf /tmp/
SQL> startup
ORACLE instance started.Total System Global Area 264241152 bytes
Fixed Size 1266944 bytes Variable Size 96471808 bytes Database Buffers 163577856 bytes Redo Buffers 2924544 bytes Database mounted. ORA-01122: database file 5 failed verification check ORA-01110: data file 5: '/app/oracle/oradata/gbk/block.dbf' ORA-01251: Unknown File Header Version read for file number 5SQL> desc v$instance
Name Null? Type ----------------------------------------- -------- ---------------------------- INSTANCE_NUMBER NUMBER INSTANCE_NAME VARCHAR2(16) HOST_NAME VARCHAR2(64) VERSION VARCHAR2(17) STARTUP_TIME DATE STATUS VARCHAR2(12) PARALLEL VARCHAR2(3) THREAD# NUMBER ARCHIVER VARCHAR2(7) LOG_SWITCH_WAIT VARCHAR2(15) LOGINS VARCHAR2(10) SHUTDOWN_PENDING VARCHAR2(3) DATABASE_STATUS VARCHAR2(17) INSTANCE_ROLE VARCHAR2(18) ACTIVE_STATE VARCHAR2(9) BLOCKED VARCHAR2(3)SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------ gbk MOUNTEDSQL> select log_mode from v$database;
LOG_MODE
------------ ARCHIVELOGSQL> host cp /tmp/block.dbf /app/oracle/oradata/gbk/
SQL> recover tablespace block
ORA-00279: change 697183 generated at 11/03/2010 11:08:17 needed for thread 1 ORA-00289: suggestion : /app/oracle/flash_recovery_area/GBK/archivelog/2010_11_03/o1_mf_1_10_%u_.arc ORA-00280: change 697183 for thread 1 is in sequence #10Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 700629 generated at 11/03/2010 14:53:14 needed for thread 1
ORA-00289: suggestion : /app/oracle/flash_recovery_area/GBK/archivelog/2010_11_03/o1_mf_1_11_%u_.arc ORA-00280: change 700629 for thread 1 is in sequence #11 ORA-00278: log file '/app/oracle/flash_recovery_area/GBK/archivelog/2010_11_03/o1_mf_1_10_6f21ptfj_. arc' no longer needed for this recoverySpecify log: {<RET>=suggested | filename | AUTO | CANCEL}
。。。。。。
ORA-00279: change 709250 generated at 11/03/2010 14:55:22 needed for thread 1
ORA-00289: suggestion : /app/oracle/flash_recovery_area/GBK/archivelog/2010_11_03/o1_mf_1_21_%u_.arc ORA-00280: change 709250 for thread 1 is in sequence #21 ORA-00278: log file '/app/oracle/flash_recovery_area/GBK/archivelog/2010_11_03/o1_mf_1_20_6f21tw39_. arc' no longer needed for this recoverySpecify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
Media recovery complete. SQL> SQL> alter database open;Database altered.
SQL> select count(*) from wwx.test;
COUNT(*)
---------- 5888到此恢复完成,实验需要的数据又重新出现在了我的面前。
也可以使用SQL> recover datafile '/app/oracle/oradata/gbk/block.dbf';恢复数据