删除数据表
最近更新时间: 2025-02-18 16:02:00
- 删除当前模式下的数据表
postgres=# drop table t;
DROP TABLE
- 删除某个模式下数据表
postgres=# drop table public.t;
DROP TABLE
- 删除数据表,不存在时不执行,不报错
postgres=# drop table IF EXISTS t;
NOTICE: table "t" does not exist, skipping
DROP TABLE
- 使用CASCADE无条件删除数据表
postgres=# create view tbase_schema.t1_view as select * from tbase_schema.t1 ;
CREATE VIEW
postgres=# drop table tbase_schema.t1 ;
ERROR: cannot drop table tbase_schema.t1 because other objects depend on it
DETAIL: view tbase_schema.t1_view depends on table tbase_schema.t1
HINT: Use DROP ... CASCADE to drop the dependent objects too.
postgres=# drop table tbase_schema.t1 CASCADE;
NOTICE: drop cascades to view tbase_schema.t1_view
DROP TABLE
postgres=#