在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=#