linux drop 数据库,drop database

温亮
2023-12-01

在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

OK至此数据库删掉完毕。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11417069/viewspace-683555/,如需转载,请注明出处,否则将追究法律责任。

 类似资料: