有時(shí)候,我們會(huì)手工創(chuàng)建一些數(shù)據(jù)庫柬泽,作為測(cè)試慎菲,結(jié)束了又需要?jiǎng)h除它們。為了以手工方式干凈的清除數(shù)據(jù)庫及相關(guān)文件锨并。需要一些明確的步驟和要求:
drop database 命令刪除數(shù)據(jù)庫
- 記錄下控制文件位置
[oracle@chengdu oradata]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 14 23:54:23 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/ORCL/controlfile/o1_mf_gj3nkplw_.ctl
/home/oracle/app/oracle/fast_recovery_area/ORCL/controlfile/o1_mf_gj3nkpmd_.ctl
- 記錄下數(shù)據(jù)文件的位置
SQL> select name from v$dbfile;
NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/CHENGDU/datafile/o1_mf_users_0au43fre_.dbf
/home/oracle/app/oracle/oradata/CHENGDU/datafile/o1_mf_undotbs1_09u43frb_.dbf
/home/oracle/app/oracle/oradata/CHENGDU/datafile/o1_mf_sysaux_08u43fq8_.dbf
/home/oracle/app/oracle/oradata/CHENGDU/datafile/o1_mf_system_07u43fp4_.dbf
SQL> /
- 記錄下重做日志文件位置
SQL> select member from v$logfile;
MEMBER
---------------------------------------------------------------------------------------------------------------------------------- --------------------
/home/oracle/app/oracle/oradata/CHENGDU/onlinelog/o1_mf_3_gj6s3p8m_.log
/home/oracle/app/oracle/fast_recovery_area/CHENGDU/onlinelog/o1_mf_3_gj6s3qc0_.log
/home/oracle/app/oracle/oradata/CHENGDU/onlinelog/o1_mf_2_gj6s3nbb_.log
/home/oracle/app/oracle/fast_recovery_area/CHENGDU/onlinelog/o1_mf_2_gj6s3o70_.log
/home/oracle/app/oracle/oradata/CHENGDU/onlinelog/o1_mf_1_gj6s3m1v_.log
/home/oracle/app/oracle/fast_recovery_area/CHENGDU/onlinelog/o1_mf_1_gj6s3ml4_.log
6 rows selected.
- 歸檔日志文件位置
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/
Oldest online log sequence 45
Next log sequence to archive 0
Current log sequence 47
- 停止偵聽
[oracle@chengdu oradata]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-JUN-2019 23:57:17
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
- 刪除數(shù)據(jù)庫
[oracle@chengdu oradata]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 14 23:57:45 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount exclusive restrict;
ORACLE instance started.
Total System Global Area 709836800 bytes
Fixed Size 2231752 bytes
Variable Size 440402488 bytes
Database Buffers 260046848 bytes
Redo Buffers 7155712 bytes
Database mounted.
SQL> alter system enable restricted session;
System altered.
SQL> drop database;
Database dropped.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
數(shù)據(jù)庫被刪除掉了露该,一并刪除的有上面的控制文件,數(shù)據(jù)文件琳疏,服務(wù)器參數(shù)文件有决,重做日志文件闸拿。我們對(duì)照上面的路徑一一檢查空盼,確認(rèn)是否都刪除干凈了。
手工刪除其余文件
- 刪除adump的文件
[oracle@chengdu admin]$ ls $ORACLE_BASE/admin/orcl
adump
[oracle@chengdu admin]$ rm -rf $ORACLE_BASE/admin/orcl
- 刪除diag下的文件
[oracle@chengdu rdbms]$ pwd
/home/oracle/app/oracle/diag/rdbms
[oracle@chengdu rdbms]$ rm -rf orcl
-刪除tnslsnr下的文件
[oracle@chengdu tnslsnr]$ rm -rf chengdu
[oracle@chengdu tnslsnr]$ pwd
/home/oracle/app/oracle/diag/tnslsnr
[oracle@chengdu tnslsnr]$
-刪除歸檔日志
[oracle@chengdu ORCL]$ pwd
/home/oracle/app/oracle/fast_recovery_area/ORCL
[oracle@chengdu ORCL]$ rm -rf
- 如果有pfile新荤、tnsnames.ora和listener.ora揽趾,酌情考慮,是否清除苛骨。因?yàn)椴皇莇bca安裝的數(shù)據(jù)庫篱瞎,所以/etc/oratab內(nèi)容不必刪除了。
至此數(shù)據(jù)庫基本清楚干凈痒芝。