Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Friday, September 4, 2015

oracle: How to delete a database


How to delete a database in Oracle:

Set the environment variables:
[oracle@collabn1 ~]$ env | grep ORA
ORACLE_SID=SHAIKDB
ORACLE_BASE=/u01/app/oracle
ORAENV_ASK=NO
ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/SHAIKPROD

oracle@collabn1 ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/product/11.2.0.2/SHAIKPROD/bin

a) Using dbca -silent

[oracle@collabn1 ~]$ dbca -silent -deletedatabase -sourcedb SHAIKDB.shaiksameer -sid SHAIKDB
Connecting to database
9% complete
14% complete
19% complete
23% complete
28% complete
33% complete
38% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instances and datafiles
66% complete
80% complete
95% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/SHAIKDB0.log" for further details.

dbca will delete the oratab entries  too.

[oracle@collabn1 ~]$ cat /etc/oratab | grep -i SHAIKDB


b)Using SQLPLUS:

[oracle@collabn1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 4 20:19:29 2015

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


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

SHAIKDB>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SHAIKDB>startup mount restrict;
ORACLE instance started.

Total System Global Area 1135747072 bytes
Fixed Size            2212656 bytes
Variable Size          318770384 bytes
Database Buffers      805306368 bytes
Redo Buffers            9457664 bytes
Database mounted.
SHAIKDB>drop database;

Database dropped.

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SHAIKDB>


Delete the oratab entry for the database manually.
vi /etc/oratab


c)Using dbca GUI

shaiks@MAC$ssh -X oracle@192.168.78.51
oracle@192.168.78.51's password:
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Fri Sep  4 20:09:10 2015 from 192.168.78.2

oracle@collabn1 ~]$ dbca









No comments: