I've many tables with relationship constraints. Tables contain filled with dummy data, i must truncate/empty the information in the tables and keep the dwelling.

Each time i wish to empty a table, i recieve foreign key constraint errors. So what can i actually do to disable the constraint temporarily after which set enable it back once dummy data are erased.

I attempted this solution, but did not work! After i disable, then attempt to truncate, i recieve fk constraint error...



I am using MySQL.

Any idea?

You need to take away the FK if you wish to use truncate, as it is not really a drenched operation. This only works if you are using delete.

Start in the finish (tables which are only FK) and never recommended BY every other tales. Individuals you are able to truncate. Then come up and remove. Should you truncate / remove within the proper order then you'll not violate the contraints. Or you might drop all of the constaints. Truncate the tables. Adding the contraints in.