I think I get foreign key constraint error when I try to truncate innodb tables. I was not having problems with this when using MyISAM.
Is there an easy way to force truncate all tables? Or should I just make a script to drop the database, create new one and then create the tables from scratch?
About the FK constraints, you could disable them with next statements -
SET FOREIGN_KEY_CHECKS = 0;
...DML statements
SET FOREIGN_KEY_CHECKS = 1; -- enable checking
If you have foreign key problems during your operation you can:
ALTER TABLE tablename DISABLE KEYS
then do your business, and afterwards re-enable keys with:
ALTER TABLE tablename ENABLE KEYS
This techinique is used in MySQL dumps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.