您好,登錄后才能下訂單哦!
oracle中怎么徹底刪除數據文件,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
物理刪除數據文件:
alter database datafile 8 offline drop;
alter database datafile 9 offline drop;
select file#,status$ from file$;
FILE# STATUS$
---------- ----------
1 2
2 2
3 2
4 2
5 2
6 1
7 2
8 2
9 2
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
SYS@hhw1> delete file$ where FILE#=8;
1 row deleted.
SYS@hhw1> delete file$ where FILE#=9;
1 row deleted.
SYS@hhw1> commit;
Commit complete.
SYS@hhw1> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------------------------------ --------------------
1 +DATA/hhw/datafile/system.256.938483503 SYSTEM
2 +DATA/hhw/datafile/sysaux.257.938483503 SYSAUX
3 +DATA/hhw/datafile/undotbs1.258.938483503 UNDOTBS1
4 +DATA/hhw/datafile/users.259.938483505 USERS
5 +DATA/hhw/datafile/undotbs2.264.938483663 UNDOTBS2
此時數據字典中的信息已刪除,但控制文件仍留有記錄,需要重建控制
alter database backup controlfile to trace as '/home/oracle/a.txt';
SYS@hhw1> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 +DATA/hhw/datafile/system.256.938483503
2 +DATA/hhw/datafile/sysaux.257.938483503
3 +DATA/hhw/datafile/undotbs1.258.938483503
4 +DATA/hhw/datafile/users.259.938483505
5 +DATA/hhw/datafile/undotbs2.264.938483663
8 +DATA/hhw/datafile/users.291.970554721 -----仍存在
9 +DATA/hhw/datafile/users.291.963587193 -----仍存在
alter system set cluster_database=false scope=spfile;
shutdown immediate
startup nomount
控制文件需要修改,去掉offline drop的數據文件:
CREATE CONTROLFILE REUSE DATABASE "HHW" NORESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+DATA/hhw/onlinelog/group_1.261.938483583' SIZE 50M BLOCKSIZE 512,
GROUP 2 '+DATA/hhw/onlinelog/group_2.262.938483583' SIZE 50M BLOCKSIZE 512,
GROUP 3 '+DATA/hhw/onlinelog/group_3.265.938483763' SIZE 50M BLOCKSIZE 512,
GROUP 4 '+DATA/hhw/onlinelog/group_4.266.938483763' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'+DATA/hhw/datafile/system.256.938483503',
'+DATA/hhw/datafile/sysaux.257.938483503',
'+DATA/hhw/datafile/undotbs1.258.938483503',
'+DATA/hhw/datafile/users.259.938483505',
'+DATA/hhw/datafile/undotbs2.264.938483663',
'+DATA/hhw/datafile/users.267.940497227'
CHARACTER SET ZHS16GBK;
alter database open;
alter system set cluster_database=true scope=spfile;
shutdown immediate
srvctl start database -d hhw
SYS@hhw1> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------------------------------ ------------------------------
1 +DATA/hhw/datafile/system.256.938483503 SYSTEM
2 +DATA/hhw/datafile/sysaux.257.938483503 SYSAUX
3 +DATA/hhw/datafile/undotbs1.258.938483503 UNDOTBS1
4 +DATA/hhw/datafile/users.259.938483505 USERS
5 +DATA/hhw/datafile/undotbs2.264.938483663 UNDOTBS2
SYS@hhw1> select file#,name from v$datafile;
FILE# NAME
---------- ------------------------------------------------------------
1 +DATA/hhw/datafile/system.256.938483503
2 +DATA/hhw/datafile/sysaux.257.938483503
3 +DATA/hhw/datafile/undotbs1.258.938483503
4 +DATA/hhw/datafile/users.259.938483505
5 +DATA/hhw/datafile/undotbs2.264.938483663
看完上述內容,你們掌握oracle中怎么徹底刪除數據文件的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。