Oracle 10g新增DROP DATABASE命令

Posted: 三月 4, 2011 in new feathers, oracle

在10g以前,要彻底删除数据库,只有两个方法,一个是利用DBCA图形化工具删除数据库,另外一个就是关闭数据库后,手工删除数据文件、控制文件以及日志文件的方法。

从10g开始,Oracle提供了DROP DATABASE的语法,使得数据库的删除变得非常的简单

不过DROP DATABASE还是有一定的限制条件的:

sqlplus / a sysdba
sql>startup mount exclusive;
sql>alter system enable restricted session;
sql>drop database;

数据库必须处于MOUNT状态,且设置了RESTRICTED SESSION。执行了DROP DATABASE命令后,Oracle自动删除控制文件,已经控制文件中记录的数据文件和在线重做日志文件,如果数据库使用了SPFILE,那么SPFILE文件也会删除。这个命令不会删除归档文件和备份文件。

在alert文件中,可以看到drop database对应的操作:

drop database
Mon May 18 06:13:01 2009
Deleted file /data/oradata/test102/system01.dbf
Deleted file /data/oradata/test102/undotbs1.dbf
Deleted file /data/oradata/test102/sysaux01.dbf
Deleted file /data/oradata/test102/redo01.log
Deleted file /data/oradata/test102/redo02.log
Deleted file /data/oradata/test102/redo03.log
Deleted file /data/oradata/test102/redo04.log
Deleted file /data/oradata/test102/redo05.log
Deleted file /data/oradata/test102/redo06.log
Deleted file /data/oradata/test102/redo07.log
Deleted file /data/oradata/test102/temp01.dbf
Instance terminated by USER, pid = 15795
Deleted file /data/oradata/test102/control01.ctl
Completed: drop database
Mon May 18 06:13:08 2009
Shutting down instance (abort)
License high water mark = 1

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s