0

I am trying to temporarily disable foreign key checks, but have not been successful.

```
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `menu_items`;
CREATE TABLE `menu_items` (
...
SET FOREIGN_KEY_CHECKS = 1;
```

It keeps telling me that I cannot delete or update a parent row. Any help would be appreciated!

Tony
  • 1
  • 2
  • This is a duplicate of [How to temporarily disable a foreign key constraint in MySQL?](https://stackoverflow.com/questions/15501673/how-to-temporarily-disable-a-foreign-key-constraint-in-mysql/29261661). Take a look -- maybe there is something there for you. – Booboo Jul 29 '19 at 10:33

1 Answers1

0

To disable foreign key constraints when you want to truncate a table:

Use FOREIGN_KEY_CHECKS

SET FOREIGN_KEY_CHECKS=0;

Or you can use DISABLE KEYS:

ALTER TABLE table_name DISABLE KEYS;
Shivani Sonagara
  • 1,299
  • 9
  • 21