手工删除非dbca创建的数据库

2019-06-15  本文已影响0人  chimpansee

有时候,我们会手工创建一些数据库,作为测试,结束了又需要删除它们。为了以手工方式干净的清除数据库及相关文件。需要一些明确的步骤和要求:

drop database 命令删除数据库

[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
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
[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

数据库被删除掉了,一并删除的有上面的控制文件,数据文件,服务器参数文件,重做日志文件。我们对照上面的路径一一检查,确认是否都删除干净了。

手工删除其余文件

[oracle@chengdu admin]$ ls $ORACLE_BASE/admin/orcl
adump
[oracle@chengdu admin]$ rm -rf $ORACLE_BASE/admin/orcl
[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

至此数据库基本清楚干净。

上一篇 下一篇

猜你喜欢

热点阅读