I have a database that has several tables. Many of the tables have fields with foreign key constraints. I want to truncate the tables and then repopulate them with new data, and I also want to take off the foreign keys, as some of the relationships have changed. basically, I want to build the FK constraints up from scratch again. How can I remove the current FK constraints from all tables?
Share
You can play with the information_schema.
Take a look at this page
http://dev.mysql.com/doc/refman/5.0/en/key-column-usage-table.html
then run the output generated.
You can do something similar in order to truncate all tables.
this one will truncate all tables within the specified database. So use it with care.