孤灯野火
畅想的天空
posts - 2,comments - 4,trackbacks - 0
在10g以前,要彻底删除数据库,只有两个方法,一个是利用DBCA图形化工具删除数据库,另外一个就是关闭数据库后,手工删除数据文件、控制文件以及日志文件的方法。 

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





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

SQL> conn / as sysdba 
Connected. 
SQL> drop database; 
drop database 

ERROR at line 1: 
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation 


SQL> alter database close; 

Database altered. 

SQL> drop database; 
drop database 

ERROR at line 1: 
ORA-12719: operation requires database is in RESTRICTED mode 


SQL> alter system enable restricted session; 

System altered. 

SQL> drop database; 

Database dropped. 

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production 
With the Partitioning, OLAP and Data Mining options 
SQL> exit 
[oracle@bjtest ~]$ ps -ef|grep test102 
oracle 15805 14913 0 06:13 pts/1 00:00:00 grep test102 

数据库必须处于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
posted on 2011-11-02 15:24 孤飞燕 阅读(2912) 评论(0)  编辑  收藏 所属分类: 数据库

只有注册用户登录后才能发表评论。


网站导航: