Drop Database

netwant發表於2013-04-19
drop database[@more@]

今天手動建庫,正執行catproc 指令碼,突然停電了。悲催呀。需要重新刪除庫重建。

在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命令。

接下來,我要重新建立資料庫了!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/309902/viewspace-1060408/,如需轉載,請註明出處,否則將追究法律責任。

相關文章