postgresql on delete cascade

前端 未结 2 966
温柔的废话
温柔的废话 2021-02-04 01:17

I have two tables:

TableY:
    id, name, description

TableX:
    id, name, y_id

I have added a foreign key in TableX (y_id

2条回答
  •  孤独总比滥情好
    2021-02-04 02:21

    I guess you got misunderstanding. Try to delete row from TableY and corresponding rows from TableX will be cascade deleted. This option is indispensable when you have secondary related tables and would like to clean them all by deleting parent row from primary table without getting constraints violated or rubbish left.

提交回复
热议问题