导航

环境 linux4+oracle10g
有全备没有丢失的数据文件的备份


[root@server ~]# su - oracle
[oracle@server ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 14 14:52:09 2011

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


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

SQL> create tablespace jason datafile '/oracle/oradata/orcl/jason01.dbf' size 10m;

Tablespace created.

SQL> create table jason_tb tablespce jason as select * from user_tables;

Table created.

SQL> commit;

Commit complete.

SQL> select count(*) from jason_tb;

  COUNT(*)
----------
       703

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oracle/oradata/orcl/system01.dbf
/oracle/oradata/orcl/undotbs01.dbf
/oracle/oradata/orcl/sysaux01.dbf
/oracle/oradata/orcl/users01.dbf
/oracle/oradata/orcl/example01.dbf
/oracle/oradata/orcl/perfstat.dbf
/oracle/oradata/orcl/jason01.dbf

7 rows selected.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !
[oracle@server ~]$ cd oradata/
[oracle@server oradata]$ ls -l
total 4
drwxr-x---  2 oracle oinstall 4096 Mar 14 14:52 orcl
[oracle@server oradata]$ cd orcl/
[oracle@server orcl]$ ls -l
total 3169720
-rw-r-----  1 oracle oinstall    7061504 Mar 14 14:53 control01.ctl
-rw-r-----  1 oracle oinstall    7061504 Mar 14 14:53 control02.ctl
-rw-r-----  1 oracle oinstall    7061504 Mar 14 14:53 control03.ctl
-rw-r-----  1 oracle oinstall  104865792 Mar 14 14:53 example01.dbf
-rw-r-----  1 oracle oinstall   10493952 Mar 14 14:53 jason01.dbf
-rw-r-----  1 oracle oinstall 2097160192 Mar 14 14:53 perfstat.dbf
-rw-r-----  1 oracle oinstall   52429312 Mar 14 00:07 redo01.log
-rw-r-----  1 oracle oinstall   52429312 Mar 14 14:53 redo02.log
-rw-r-----  1 oracle oinstall   52429312 Mar 14 00:07 redo03.log
-rw-r-----  1 oracle oinstall  283123712 Mar 14 14:53 sysaux01.dbf
-rw-r-----  1 oracle oinstall  513810432 Mar 14 14:53 system01.dbf
-rw-r-----  1 oracle oinstall   20979712 Mar 13 22:34 temp01.dbf
-rw-r-----  1 oracle oinstall   31465472 Mar 14 14:53 undotbs01.dbf
-rw-r-----  1 oracle oinstall    5251072 Mar 14 14:53 users01.dbf
[oracle@server orcl]$ rm jason01.dbf    --------模拟此数据文件丢失,此数据文件没有备份
[oracle@server orcl]$ exit
exit

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@server ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 14 14:54:46 2011

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218968 bytes
Variable Size              79693416 bytes
Database Buffers          197132288 bytes
Redo Buffers                7168000 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/orcl/jason01.dbf'


SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 7: '/oracle/oradata/orcl/jason01.dbf'
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/orcl/jason01.dbf'


SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> alter database create datafile 7;

Database altered.

SQL> recover datafile 7;
Media recovery complete.
SQL> alter database open;

Database altered.

[oracle@server orcl]$ ls
control01.ctl  control03.ctl  jason01.dbf   redo01.log  redo03.log    system01.dbf  undotbs01.dbf
control02.ctl  example01.dbf  perfstat.dbf  redo02.log  sysaux01.dbf  temp01.dbf    users01.dbf

7 rows selected.

SQL> select count(*) from jason_tb;

  COUNT(*)
----------
       703

SQL>

呵呵,其实说白了就两句:
SQL> alter database create datafile 7;
SQL> recover datafile 7;