Export and import foreign Keys
We've tranfered a site to a new server and now it's been running for th开发者_开发知识库ree days without any foreign keys being active.
How can I:
- Export the foreign keys from the old structure (100+ tables)
- Import the keys while ignoring integrity problems
- Discard all the records where the foreign key are missing
Create two dumps (current/imported) and use a database diff tool, or generate the alter table statements by pulling the data from the information schema.
SET foreign_key_checks = 0;
to disable,SET foreign_key_checks = 1;
to enable.Use left join statements and search for null values in the outer table.
精彩评论