在oracle 10g里,有一条新特性是使用drop database命令可以删除数据库的数据文件,联机日志文件,控制文件,spfile.使用drop database命令需要以下三个条件:
- database moust be closed
- exclusively mounted
- restricted mode
下面是实验的过程:
Enter user-name: / as sysdba
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1248720 bytes
Variable Size 134218288 bytes
Database Buffers 171966464 bytes
Redo Buffers 7139328 bytes
Database mounted.
Database opened.
SQL>
在数据库完全打开的情况下使用drop database命令
SQL>
SQL> drop database;
drop database
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation
将数据库关闭,重新启动到mount状态
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1248720 bytes
Variable Size 138412592 bytes
Database Buffers 167772160 bytes
Redo Buffers 7139328 bytes
Database mounted.
再次执行drop database命令,执行命令出现错误
SQL> drop database;
drop database
*
ERROR at line 1:
ORA-12719: operation requires database is in RESTRICTED mode
将数据库模式置为restricted模式
SQL> alter system enable restricted session;
System altered.
执行drop database删除数据库命令成功
SQL> drop database;
Database dropped.
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
看来要正确执行这条命令,这三个条件都要满足。我查看了一下数据文件,日志文件,控制文件,spfile确实不存在了。我是在Windows上做的测试,操作系统上ORACLE实例的服务还存在着,如果想完全清楚oracle,再用oradim -delete -sid sidname命令。
接下来,我要重新创建数据库了!