我是PostgreSQL的新手,我觉得一个简单的命令DROP DATABASE
和DROPDB
有问题,为什么下面的命令不能删除我的数据库?
postgres=# drop database clientms
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------------+----------+-------------+-------------+-----------------------
clientms | clientmsuser | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
postgres-# dropdb clientms
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------------+----------+-------------+-------------+-----------------------
clientms | clientmsuser | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
4条答案
按热度按时间vm0i2vca1#
您忘记了命令后的分号
;
。请尝试:不完整的命令也会由提示符指示:
-
而不是=
。这是为了允许多行命令。对于其他情况,不考虑简单语法问题:
yqkkidmi2#
**使用PGAdmin:**检查您是否与服务器连接,转到您的数据库并右键单击它,然后删除该数据库。刷新数据库或重新打开服务器!
手动执行:
ru9i0ody3#
令人恼火的是,我已经解决了这个问题,但一年多以后又遇到了这个问题,而且用了一种不同的方法来解决它,因为我没有注意到我已经得到了如何解决它的笔记。
http://www.itsupportforum.net/topic/unable-to-delete-drop-postgresql-database/
总之,我不能删除数据库,因为我用来删除它的接口正在使用它。
qoefvg9y4#
显然
destroydb clientms
工作正常(不过我花了很多时间)link(http://www.yolinux.com/TUTORIALS/LinuxTutorialPostgreSQL.html)