Wednesday, May 04, 2011

drop database command


The Drop Database command, that made a fast and efficient cleanup of all files below in one command.

  1. Data files
  2. Redo logs
  3. Control files
  4. spfile  -  If the database used a server parameter file (spfile), it is also deleted

Archived logs and backups are not removed, but you can use Recovery Manager (RMAN) to remove them.

Drop database do require to mount the database in exclusive restricted mode, that made quite difficult to execute it by mistake on the wrong database.

The steps are as follows:

shutdown abort;
startup mount exclusive restrict;
drop database;

This is a sample session using this feature:

1) Check Datafile, Controlfile and Online log names before drop database

  select name from v$database;
  select name from v$datafile;
  select member from v$logfile;
  select name from v$controlfile;

2) Drop Database

shutdown abort
ORACLE instance shut down.
startup mount exclusive restrict;
ORACLE instance started.

Total System Global Area  989855744 bytes
Fixed Size                  2077552 bytes
Variable Size             864029840 bytes
Database Buffers          117440512 bytes
Redo Buffers                6307840 bytes
Database mounted.
drop database;
Database dropped.

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

3) Check Datafile/Redologs/Controlfile after drop database

 ls -ltr

No comments: