DROP SCHEMA

删除模式的 SQL 命令

DROP SCHEMA 是用于删除模式的 DDL 命令。

DROP SCHEMAPostgreSQL 7.3 中添加。

变更历史

示例

删除空模式

postgres=# CREATE SCHEMA foo;
CREATE SCHEMA

postgres=# DROP SCHEMA foo;
DROP SCHEMA

删除非空模式

postgres=# CREATE SCHEMA foo;
CREATE SCHEMA

postgres=# CREATE TABLE foo.bar (id INT, val TEXT);
CREATE TABLE

postgres=# DROP SCHEMA foo;
ERROR:  cannot drop schema foo because other objects depend on it
DETAIL:  table foo.bar depends on schema foo
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

postgres=# DROP SCHEMA foo CASCADE;
NOTICE:  drop cascades to table foo.bar
DROP SCHEMA

分类

DDL, Schema (namespace), SQL command

另请参阅

CREATE SCHEMA, ALTER SCHEMA, pg_namespace

反馈

提交任何关于“DROP SCHEMA”的评论、建议或更正,请在此处 提交