Manual removal of databases in Oracle tutorial _oracle

Source: Internet
Author: User
Tags sqlplus

In many cases, or when the DBCA tool cannot be used, we need to manually delete the database. This can be accomplished by using the drop Database command, which is given in the following description to manually delete the databases.

The specific steps of the file system database and the ASM database. Environment: Oracle Enterprise Linux 5.4 + Oracle 10g R2.

First, manually delete the file system database

1. Stop Listening and OEM

Copy Code code as follows:

$ lsnrctl Stop Listener_name
$ emctl Stop Dbconsole

2. Access to data files, log files and control documents related information, including archiving

Copy Code code as follows:

$ sqlplus/as SYSDBA
Sql> select Status,name from V$controlfile; --Get the location information of the control file
Sql> select * from V$dbfile; --Get location information for data files
Sql> select * from V$logfile; --Get the location information of the log file
sql> archive log list; --View archived sequence and location information
sql> shutdown abort; --Direct shutdown abort because data is no longer needed

3. Boot to mount state (using exclusive restart)

Copy Code code as follows:

Sql> startup Mount exclusive restrict;

4. Modify parameter to allow restricted session mode

Copy Code code as follows:

Sql> alter system enable restricted session;

5. Use the drop database command to purge the databases

Copy Code code as follows:

sql> drop database;
Sql> exit

6. Manually Erase related files

Copy Code code as follows:

$ echo $ORACLE _sid--Confirm the current Oracle_sid
$ rm-rf $ORACLE _base/admin/$ORACLE _sid--Delete all contents of $oracle_sid under ORACLE BASE directory
$ RM-RF $ORACLE _base/oradata/$ORACLE The data file under _sid--oradata, according to the previous query, note that you want to delete the data files under different paths
$ rm-rf $ORACLE _base/arch/$ORACLE _sid--Clear the archive log, and pay attention to the correctness of the archive path
$ rm-rf $ORACLE _base/flash_recovery_area/$ORACLE _sid--Clear the contents of the flashback area
$ rm-rf $ORACLE _home/dbs/* $ORACLE _sid*--Clear parameter file */

7. Clear and monitor related documents (recommended)

Copy Code code as follows:

$ rm $TNS _admin/*.ora--If you set the $tns_admin variable, delete the listener file under the default path.
$ RM $ORACLE _home/network/admin/*.ora * *

8. Modify Oratab files and. bash_profile
Copy Code code as follows:

$ vi/etc/oratab--Remove the settings associated with the instance
$ VI ~/.bash_profile--Remove the settings associated with the instance

Ii. Elimination of the ASM database

The difference between the ASM database deletion and the file system database is that data files, control files, log files, parameter files, etc. are stored in the ASM system and therefore need to be done in the ASM instance
Action to completely erase the database.

1. Perform the file system database Cleanup Step 3-4 step (shutdown first)

2. Use the drop database command to purge the databases (the command clears data files, log files, temp files)

Copy Code code as follows:

sql> drop database;
Sql> exit

3. Connecting to ASM instances
Copy Code code as follows:

$ Export Oracle_sid=+asm
$ sqlplus/as SYSDBA

4. Clear residual files

Copy Code code as follows:

Sql> select Name,file_number,group_number,file_incarnation from V$asm_alias; --View files, note that Group_number is located on different disk groups
sql> alter diskgroup DG1 drop directory ' +dg1/asmdb/file_name '; --You can use the method to remove files that need to be deleted
sql> alter diskgroup REV drop directory ' +rev/asmdb/file_name ';
Sql> select Name,file_number,group_number,file_incarnation from V$asm_alias; --Verify the results of the deletion

You can also use the following method (Asmcmd command) to delete the remaining files
Copy Code code as follows:

$ Export Oracle_sid=+asm
$ asmcmd
Asmcmd> ls-l
State Type Rebal Unbal Name
Mounted EXTERN n N dg1/
Mounted EXTERN n N rev/
Asmcmd> ls-s
Sector block AU total_mb free_mb req_mir_free_mb usable_file_mb offline_disks Name
4096 1048576 3067 2974 0 2974 0 dg1/
4096 1048576 2047 1996 0 1996 0 rev/
Asmcmd> CD +DG1
Asmcmd> ls
asmdb/
Asmcmd> RM-RF Asmdb
Asmcmd> ls
Asmcmd> CD +rev
asmcmd> pwd
+rev
Asmcmd> ls
Asmcmd> CD +
Asmcmd> ls-s
Sector block AU total_mb free_mb req_mir_free_mb usable_file_mb offline_disks Name
4096 1048576 3067 3016 0 3016 0 dg1/
4096 1048576 2047 1996 0 1996 0 rev/

You can also use the RM command to delete files directly from files that are located directly under the disk group

5. Clear other documents

Although data files, archive logs, online logs, temporary files, parameter files are stored in the ASM disk, but the dump file, the alert log is still on the disk, you need to manually clear

Copy Code code as follows:
$ echo $ORACLE _sid--Confirm the current Oracle_sid
$ rm-rf $ORACLE _base/admin/$ORACLE _sid--Delete all contents of $oracle_sid under ORACLE BASE directory
$ rm-rf $ORACLE _home/dbs/* $ORACLE _sid*--Clear parameter file */

6. Perform the file system database cleanup step 7-8 step

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.