Postgresql 中文操作指南
23.5. Destroying a Database #
数据库可以用命令 DROP DATABASE 删除:
Databases are destroyed with the command DROP DATABASE:
DROP DATABASE name;
只有数据库所有者或超级用户才能删除数据库。删除数据库将删除包含在数据库中的所有对象。数据库的破坏不能撤销。
Only the owner of the database, or a superuser, can drop a database. Dropping a database removes all objects that were contained within the database. The destruction of a database cannot be undone.
连接到受害者数据库时,不能执行 DROP DATABASE 命令。但是,可以连接到任何其他数据库,包括 template1 数据库。template1 将是删除给定集群的最后一个用户数据库的唯一选项。
You cannot execute the DROP DATABASE command while connected to the victim database. You can, however, be connected to any other database, including the template1 database. template1 would be the only option for dropping the last user database of a given cluster.
为了方便,还有一个 Shell 程序用于删除数据库, dropdb :
For convenience, there is also a shell program to drop databases, dropdb:
dropdb dbname
(与 createdb 不同,删除具有当前用户名的数据库不是默认操作。)
(Unlike createdb, it is not the default action to drop the database with the current user name.)