I needed to load some lookup data into a MySQL database littered with foreign keys. So I copied the empty DB and ran the output of the following:
[cc lang=’sql’ ]
SELECT CONCAT(‘alter table ‘,table_schema,’.’,table_name,’ DROP FOREIGN KEY ‘,constraint_name,’;’)
WHERE constraint_type=’FOREIGN KEY’ AND table_schema = ‘MY_DATABASE_NAME_HERE’; [/cc]
I loaded the values, and dumped just the values (only insert statements) that I will use to populate the version of the DB with my FK’s intact.