1.) Create a tablespace SQL> create tablespace my_test datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' size 200k; Tablespace created. 2.) Accidentally, the datafile belonging to this tablespace was deleted $ rm /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf 3.) Try resizing the datafile SQL> alter database datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' resize 250k; alter database datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' resize 250k * ERROR at line 1: ORA-01565: error in identifying file '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
$ ps -ef |grep EMR102U6|grep dbw emrdbms 21943 1 0 10:27:08 ? 0:00 ora_dbw0_EMR102U62.)使用lsof命令为该 ospid 找到打开的文件
$ lsof -p 21943 |grep /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf Command PID USER FD TYPE DEVICE SIZE/OFF NODE NAME oracle 21943 emrdbms 270uW VREG 304,25 212992 11273825 /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf注意:
--> $ cd /proc/ <process_id> / <file_descriptor_directory>'/
$ cd /proc/21943/fd/
4.)将该表空间read onlyalter tablespace my_test read only;将表空间置为read only 冻结了文件头,防止文件头的更新。因为 当database 处于open时,只有在datafile 处于read only状态下 才可能copy 该file。
5.)对该文件做一个copy
$ cat 270 > /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf
6.)为了确保 该file 的copy在 copy后没有被使用,执行如下:a) Take datafile offline alter tablespace my_test offline; Query the view v$datafile to verify the datafile is offline: select status from v$datafile where file#=<file number>; b) Bring datafile back online alter tablespace my_test online;
alter tablespace my_test read write;Query view dba_tablespaces to check status of the tablespace: