Sql server - recursive delete

后端 未结 5 2082
别跟我提以往
别跟我提以往 2020-12-28 19:59

I\'m trying to delete user\'s data and all it\'s related data that is located in different tables. All the tables have Foreign Keys but without cascade delete.

I in

5条回答
  •  星月不相逢
    2020-12-28 20:15

    Cascade delete is easy, well-performing and reliable. Works over multiple levels. The query plans are interesting and seem well-optimized.

    If you want manual deletes, make sure to issue just one query per table for efficiency reasons. You can use joins in a delete statement to join to the parent level(s) to filter the rows to be deleted.

提交回复
热议问题