1. 程式人生 > 其它 >臨時表空間故障處理 (33天)

臨時表空間故障處理 (33天)

最近測試環境需要把一些現有的儲存空間勻出一部分來給新增的環境使用。 unix組的人很快就空間按照指定的比例重新切分好了。環境交給我的時候,我先把資料庫起來,沒有任何問題,因為需要到處一個建立使用者的語句,就簡單執行了一個查詢。 select dbms_metadata.get_ddl('USER',u.username) from dba_users u WHERE USERNAME in('TEST'); 但是讓我意外的,報瞭如下的錯誤。 SQL> select dbms_metadata.get_ddl('USER',u.username) from dba_users u WHERE USERNAME in('TEST'); ERROR: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' ORA-06512: at "SYS.DBMS_METADATA", line 4018 ORA-06512: at "SYS.DBMS_METADATA", line 5843 ORA-06512: at line 1 no rows selected

想資料檔案被清掉了,先給offline了重新配置一下。 offline不可以,offline drop也不行。 SQL> alter database datafile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' offline; alter database datafile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' offline * ERROR at line 1: ORA-01516: nonexistent log file, data file, or temporary file "/u01/oracle/TEST/oratmp01/temp/temp01.dbf" SQL> alter database datafile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' offline drop; alter database datafile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' offline drop * ERROR at line 1: ORA-01516: nonexistent log file, data file, or temporary file "/u01/oracle/TEST/oratmp01/temp/temp01.dbf"
我說不能offline,offline drop,有的人說得放在mount狀態下執行,我試了也不行。 我直接刪除表空間重新建得了,oracle已經開始給我哭窮了,說不能刪除預設的臨時表空間。 SQL> drop tablespace temp including contents and datafiles; drop tablespace temp including contents and datafiles * ERROR at line 1: ORA-12906: cannot drop default temporary tablespace 那我刪除這個臨時檔案,oracle又說這個臨時表空間裡只有一個數據檔案。 SQL> alter tablespace temp drop tempfile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf'; alter tablespace temp drop tempfile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf' * ERROR at line 1: ORA-03261: the tablespace TEMP has only one file
我還是自己檢視下資料夾到底在不在。一查資料夾都被清掉了。 SQL> !ls -l /dbusgsPT1/oracle/PETUSG1/oratmp01/temp ls: /dbusgsPT1/oracle/PETUSG1/oratmp01/temp: No such file or directory 先把資料夾給補上 SQL> !mkdir -p /u01/oracle/TEST/oratmp01/temp 建立一個別名的臨時檔案,馬上見temp01的臨時資料檔案還不行。 SQL> alter tablespace temp add tempfile '/u01/oracle/TEST/oratmp01/temp/temp02.dbf' size 20G; Tablespace altered. 然後再去刪除其實不存在的臨時資料檔案。從資料字典裡進行更新。 SQL> alter tablespace temp drop tempfile '/u01/oracle/TEST/oratmp01/temp/temp01.dbf'; Tablespace altered. 後續就如果需要可以把臨時資料檔案的名字從temp02.dbf改成temp01.dbf