Pages

Tuesday, February 16, 2016

Oracle Drop Database in LINUX

Oracle Drop Database in LINUX

Dropping a database will remove all corresponding datafiles, redo log files and control files. The database must be mounted in exclusive and restricted mode.

Drop database command will not do any effect on archived log files and backups of the database. Drop database command will not delete the files on RAW disks.
If you created your database with DBCA, you can use the same DBCA tool to drop the database.

Example.

$export ORACLE_SID=DEVDB
$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 28 18:18:41 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>DROP DATABASE;

DROP DATABASE
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation

NOTE :  Drop database does not work when the database is opened in normal open mode

SQL > shut immediate
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.

Total System Global Area 282352256 bytes
Fixed Size                  2132856 bytes
Variable Size            1644174848 bytes
Database Buffers         1140850688 bytes
Redo Buffers               36388864 bytes
Database mounted.

SQL> alter system enable restricted session;
System altered.

Or open the database using “startup mount Restrict” command

SQL> drop database;
Database dropped.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Now, all the Control files, redo log files and Datafiles are automatically removed but you can still see the Parameter file and archivelog files.

Note:If your database is running on windows you have to remove the registry entries manually.

No comments:

Post a Comment