[英]In postgresql, what's the difference a “database” and a “relation”? ('error relation x does not exist', 'error database x already exists')
[英]DBeaver / PostgreSQL: "Error: database already exists", but I can't find it
我想通過右鍵單擊PostgreSQL並選擇Create Database來創建名為“President”的數據庫。
但是,我在下面的屏幕打印中收到錯誤。
我可以創建具有其他名稱的數據庫,例如SomeOtherDatabase和SomeOtherDatabase2 (參見屏幕截圖)。
有什么想法可以找到並刪除似乎已經存在的數據庫“President”嗎?
更新!!
如果我執行
select * from pg_database
我得到以下結果:
所以數據庫“總統”似乎確實存在。 (同時我刪除了 someOtherDatabase和someOtherDatabase2 。)
但是,如果我執行
drop database President
我得到:
您可以查詢目錄視圖pg_database
以檢查數據庫是否已存在:
select datname from pg_database WHERE datname = 'president'
並使用drop database
刪除它:
drop database president;
請注意,Postgres 的drop database
語法支持if exists
子句,這在您的用例中可能會派上用場:
drop database if exists president;
您可以右鍵單擊postgres
數據庫並 select edit connection
選項。 在 PostgreSQL 選項卡下,選中Show all databases
選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.