在PostgreSQL中,定義父子表後,子表可以随便删除,但是父表删除時,必須使用CASCADE級聯删除或者先把子表都删了,示例如下:
postgres=# drop table cities;
ERROR: cannot drop table cities because other objects depend on it
DETAIL: table capitals depends on table cities
HINT: Use DROP ... CASCADE to drop the dependent objects too.
postgres=# drop table cities cascade;
NOTICE: drop cascades to table capitals
DROP TABLE
postgres=#