Fra*_*ank 15 sql database postgresql create-table dbeaver
我想通过右键单击PostgreSQL并选择Create Database来创建名为“President”的数据库。
但是,我在下面的屏幕截图中收到错误。
我可以使用其他名称创建数据库,例如SomeOtherDatabase和SomeOtherDatabase2(请参阅屏幕截图)。
我有什么想法如何找到并删除似乎已经存在的数据库“总统”?
更新!!
如果我执行
select * from pg_database
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
所以数据库“President”似乎确实存在。(同时我删除了someOtherDatabase和someOtherDatabase2。)
但是,如果我执行
drop database President
Run Code Online (Sandbox Code Playgroud)
我得到:
小智 49
您可以右键单击postgres数据库并选择edit connection选项。在 PostgreSQL 选项卡下,选中该Show all databases选项。
您可以查询目录视图pg_database来检查数据库是否已存在:
select datname from pg_database WHERE datname = 'president'
Run Code Online (Sandbox Code Playgroud)
并将其删除drop database:
drop database president;
Run Code Online (Sandbox Code Playgroud)
请注意,Postgres 的drop database语法支持该if exists子句,这在您的用例中可能会派上用场:
drop database if exists president;
Run Code Online (Sandbox Code Playgroud)