How to permanently delete an Oracle database to create a database with the same instance name
I chose the OMF method when creating the database today. The result file name is automatically named in Oracle. I cannot understand it, so I decided to delete it and recreate it.
Oracle provides the command to delete a database: drop database.
The database needs to be in the mount state, and then alter system enable restricted session; there is a post on the Internet saying that exclusive is also required. Because I installed VM, I only have one user, so no need to use it. Because the current status is open, you need to change it to mount and execute:
SQL> alter database close;
Alter database close
*
ERROR at line 1:
ORA-01093: alter database close only permitted with no sessions connected
The reason is that a session is still connected and is executed again after exiting,
SQL> alter database close;
Database altered.
SQL> select status from v $ instance;
STATUS
------------
MOUNTED
SQL> alter system enable restricted session;
System altered.
SQL> select status from v $ instance;
STATUS
------------
MOUNTED
SQL> drop database;
Database dropped.
In this case, the alert. log record information:
Create Relation ADR_CONTROL
Create Relation ADR_INVALIDATION
Create Relation INC_METER_IMPT_DEF
Create Relation INC_METER_PK_IMPTS
USER (ospid: 8748): terminating the instance
Instance terminated by USER, pid = 8748
Deleted Oracle managed file/opt/app/ora11g/oradata/BISAL/controlfile/o1_mf_9x4fgq77 _. ctl
Deleted Oracle managed file/opt/app/ora11g/flash_recovery_area/BISAL/controlfile/o1_mf_9x4fgypb _. ctl
Completed: drop database
Shutting down instance (abort)
License high water mark = 2
Fri Jul 25 19:09:26 2014
Instance shutdown complete
There are no files in the oradata path, so I think this database has been deleted.
However, if you attempt to create a database of the same instance by executing dbca again, an error is returned:
Although the data files and log files associated with the bisal instance have been physically deleted, the configuration files related to the instance are not deleted, so you cannot create a database for the same instance again.
In this case, you need to manually delete the instance configurations:
1. Delete all directories of $ ORACLE_BASE/admin/$ ORACLE_SID.
2. Delete SID-related files and parameter files under $ ORACLE_HOME/dbs, including hc_bisal.dat, init. ora, lkBISAL, and orapwbisal.
3. Delete the instances in/etc/oratab.
4. You can run find.-name bisal in $ ORACLE_HOME to delete all instance-related files.
Run dbca again to create a database with the same instance name.