Sunday, May 10, 2020

Steps to drop oracle database manually

Steps to drop oracle database manually





Prerequisite Steps

send mail to application team that you going to drop database 
spool the output of datafiles, redo logs, etc



Step 1: Connect to the database with sysdba privilege after that execute below query  and keep output

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


output 

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ritvik/data01/system.258.1039853925
/u01/app/oracle/oradata/ritvik/data01/sysaux.257.1039853883
/u01/app/oracle/oradata/ritvik/data01/undotbs1.260.1039853971
/u01/app/oracle/oradata/ritvik/data01/example.266.1039854013
/u01/app/oracle/oradata/ritvik/data01/users.259.1039853969

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ritvik/control01.ctl

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ritvik/group_3.264.1039854011
/u01/app/oracle/oradata/ritvik/group_2.263.1039854011
/u01/app/oracle/oradata/ritvik/group_1.262.1039854011

SQL>

Step 2: Shutdown the database

shut immediate;

Step 3: Start the database in Exclusive mode

startup mount exclusive restrict;
startup mount restrict;




[oracle@ip-10.0.0.1 data02]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Sat May 9 16:42:01 2020

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

Connected to an idle instance.

SQL> startup mount restrict;
ORACLE instance started.

Total System Global Area 2466250752 bytes
Fixed Size                  2927384 bytes
Variable Size             671089896 bytes
Database Buffers         1778384896 bytes
Redo Buffers               13848576 bytes
Database mounted.
SQL>


Step 4: Drop the database


SQL> drop database;

Database dropped.

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
SQL>
SQL> exit
[oracle@ip-10.0.0.1 data02]$
[oracle@ip-10.0.0.1 data02]$
[oracle@ip-10.0.0.1 data02]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Sat May 9 16:43:07 2020

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

Connected to an idle instance.

SQL> exit
Disconnected
[oracle@ip-10.0.0.1 data02]$
[oracle@ip-10.0.0.1 data02]$

Step 5: Post Change Steps


  •  Cross verify if all the associated datafiles, comntrolfile and online redo logs are removed
  •  Remove the directories if not required
  •  Remove the entry of the database from /etc/oratab
  •  Modify/drop any of the scripts used for this database 
  •  Remove database details from catalog database
  •  Drop backup, archive log and other script associated with the database

No comments:

Post a Comment