简体   繁体   中英

DBeaver / PostgreSQL: "Error: database already exists", but I can't find it

I want to create database called "President" by rightclicking on PostgreSQL and selecting Create Database .

However, I get the error in the screenprint below.

I can create databases with other names like SomeOtherDatabase and SomeOtherDatabase2 (see screenprints).

Any ideas how I can find and delete the database "President" that seems to exist already?

在此处输入图像描述 在此处输入图像描述

UPDATE!!

If I execute

select * from pg_database 

I get the following result:

在此处输入图像描述

So database "President" does seem to exist. (Meanwhile I deleted someOtherDatabase and someOtherDatabase2 .)

However, if I execute

drop database President

I get:

在此处输入图像描述

2023 Update

  1. Right-click on your connection
  2. Click "Edit connection"
  3. Left panel, click "Connection settings"
  4. Select PostgreSQL tab Check the box "Show all databases"

在此处输入图像描述

在此处输入图像描述

You can query catalog view pg_database to check if the database already exists:

select datname from pg_database WHERE datname = 'president'

And drop it with drop database :

drop database president;

Note that Postgres' drop database syntax supports the if exists clause, which may come handy in your use case:

drop database if exists president;

You can right click on the postgres database and select edit connection option. Under the PostgreSQL tab, check the Show all databases option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM