PostgreSQL
上一頁   下一頁

DROP DATABASE

名稱

DROP DATABASE ─ 刪除一個現有資料庫。

DROP DATABASE name
  

輸入

name
將要被刪除的資料庫名。

輸出

DROP DATABASE
如果命令成功執行,返回此命令。
ERROR: user 'username' is not allowed to create/drop databases
要刪除資料庫你必須有特殊的 CREATEDB 權限。參閱 CREATE USER
ERROR: dropdb: cannot be executed on the template database
template1 資料庫不能被刪除。它和你無關。
ERROR: dropdb: cannot be executed on an open database
你無法與你要刪除的資料庫建立聯接。你可以與 template1 或者任何其他資料庫聯接然後再次運行這條命令。
ERROR: dropdb: database 'name' does not exist
如果聲明的資料庫不存在,返回此資訊。
ERROR: dropdb: database 'name' is not owned by you
你必須是資料庫所有者。資料庫所有者通常也意味著你是創建者。
ERROR: dropdb: May not be called in a transaction block.
執行這條命令之前你必須先結束正在處理的事務。
NOTICE: The database directory 'xxx' could not be removed.
資料庫被刪除了(否則會有其他錯誤資訊),但是儲存數據的目錄無法刪除。你必須手工刪除之。

描述

DROP DATABASE 刪除一個現存資料庫的目錄入口並且刪除包含數據的目錄。只有資料庫所有者能夠執行這條命令(通常也是資料庫創建者)。

注意

這條命令在和目標資料庫聯接時不能執行。通常更好的做法是用 dropdb 腳本代替,該腳本是此命令的一個封裝。

請參考 CREATE DATABASE 語句獲取如何創建資料庫的資訊。

兼容性

SQL92

DROP DATABASE 是一個 Postgres 語言的擴展。在 SQL92 中沒有 DROP DATABASE。


上一頁 首頁 下一頁
DROP AGGREGATE 開頭 DROP FUNCTION