How to delete data from multiple tables?

前端 未结 5 883
广开言路
广开言路 2021-01-07 17:09

I have these tables:

event     (evt_id, evt_code, reg_id)

magnitude (mag_id, evt_id, value)

trace     (trace_id, pt_id)

point     (         


        
5条回答
  •  走了就别回头了
    2021-01-07 18:01

    If the rows you want to delete can be envisioned as a hierarchy, you could define FOREIGN KEY constraints for the relationships with the ON DELETE CASCADE clause. Deleting the row at the top will then cascade down and delete them all.

    http://www.postgresql.org/docs/9.1/static/ddl-constraints.html#DDL-CONSTRAINTS-FK

提交回复
热议问题