关于drop database

本文介绍了如何在Oracle数据库中安全地执行drop database操作。首先,需要将数据库切换到MOUNT EXCLUSIVE状态,然后确认状态,最后执行drop命令。这个过程不会删除归档文件和备份,确保了数据的安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       经常听到删库跑路,刚刚好读《Oracle  Database Administrator s Guide  11g Release 2 (11.2) 》有个drop database,搞一波。

SQL> drop database;
drop database
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation

#不能直接删除,需要将数据库开启到mount EXCLUSIVE状态先关闭数据库

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

#启动到mount状态:

SQL> startup mount;
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                  2257352 bytes
Variable Size             478154296 bytes
Database Buffers          301989888 bytes
Redo Buffers                2596864 bytes
Database mounted.

#将数据库设置为EXCLUSIVE状态:

SQL> alter system enable restricted session; 

System altered. 

#确认数据库状态

SQL> select status,logins from v$instance; 

STATUS           LOGINS
---------------- ----------------------
MOUNTED          RESTRICTED

#drop数据库

SQL> drop database;

Database dropped.

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

#看alter.log可以看到drop日志进行了删除操作

drop database
Deleted file /oradata/orcl/system01.dbf
Deleted file /oradata/orcl/sysaux01.dbf
Deleted file /oradata/orcl/undotbs01.dbf
Deleted file /oradata/orcl/users01.dbf
Deleted file /oradata/orcl/example01.dbf
Deleted file /oradata/orcl/redo01.log
Deleted file /oradata/orcl/redo02.log
Deleted file /oradata/orcl/redo03.log
Deleted file /oradata/orcl/temp01.dbf
Deleted file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f
Shutting down archive processes
Archiving is disabled


       启动数据库到 MOUNTED RESTRICTED状态后方可执行,删除了控制文件、数据文件以及其他记录在控制文件的文件
不会删除归档文件以及备份文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值