使用閃回恢復刪除表空間。
以下為擷取的alert日誌
Fri Apr 12 16:28:51 2024 drop tablespace users including contents and datafiles Fri Apr 12 16:28:57 2024 Deleted Oracle managed file +DATA/ORCL/DATAFILE/users.280.1166105459 Completed: drop tablespace users including contents and datafiles
由alert日誌可知,16:28:51刪除表空間USERS,現在想恢復表空間USERS。
使用閃回資料庫:
1 SQL> shutdown abort 2 ORACLE instance shut down. 3 SQL> startup mount 4 ORACLE instance started. 5 6 Total System Global Area 1073741824 bytes 7 Fixed Size 2932632 bytes 8 Variable Size 675283048 bytes 9 Database Buffers 390070272 bytes 10 Redo Buffers 5455872 bytes 11 Database mounted. 12 SQL> flashback database to timestamp to_timestamp('2024-04-12:16:28:50','yyyy-mm-dd:hh24:mi:ss'); 13 14 Flashback complete. 15 16 SQL> alter database open read only; 17 18 Database altered.
檢視v$datafile檢視,發現USERS表空間資料檔案為UNNAMED00004。
原因是現在的控制檔案內不包含此資料檔案的資訊,故閃回資料庫後不能恢復該資料檔案。
因此,對於物理結構發生變化的資料庫,謹慎使用閃回操作進行恢復。
SQL> select TABLESPACE_NAME ,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE EXAMPLE ONLINE
SQL> select name from v$datafile; NAME ---------------------------------------------------------------------------------------- +DATA/ORCL/DATAFILE/system.278.1165676991 +DATA/ORCL/DATAFILE/sysaux.285.1165676991 +DATA/ORCL/DATAFILE/undotbs1.273.1165676991 /u01/app/oracle/product/12.1.0/dbhome_2/dbs/UNNAMED00004 +DATA/ORCL/DATAFILE/example.286.1166022723