删除模式

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# drop schema tbase_new;
DROP SCHEMA

当模式中存在对象时,则会删除失败,提示如下:

  • 复制
    复制成功
postgres=# create table tbase_pgxz.t(id int);
NOTICE:  Replica identity is needed for shard table, please add to this table through "alter table" command.
CREATE TABLE
postgres=# drop schema tbase_pgxz;
ERROR:  cannot drop schema tbase_pgxz because other objects depend on it
DETAIL:  table tbase_pgxz.t depends on schema tbase_pgxz
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

可以这样强制删除:

  • 复制
    复制成功

postgres=# drop schema tbase_pgxz CASCADE;
NOTICE:  drop cascades to table tbase_pgxz.t
DROP SCHEMA