For example, I have these tables and data:
TABLE: logo_user
+----+---------+
| id | logo_id |
+----+---------+
| 1 | 1 |
| 2 | 2 |
+----+---------+
TABLE: logo
+----+
| id |
+----+
| 1 |
| 2 |
+----+
What I want is to delete every rows in logo
table, and nullify the values that refers to it. Example:
TABLE: logo_user
+----+---------+
| id | logo_id |
+----+---------+
| 1 | NULL |
| 2 | NULL |
+----+---------+
TABLE: logo (now emptied)
- I tried using
TRUNCATE ... CASCADE
but it also deleted every rows in thelogo_user
table. - I also consider altering the foreign key constraint of the
logo_user
to cascade on delete, but it's too much work. In reality I have many tables referring tologo
table.