List:General Discussion« Previous MessageNext Message »
From:Dominik Klein Date:July 20 2006 11:10am
Subject:How to disable foreign_key_checks when using mysqlimport?
View as plain text  
Hello

When I re-insert dumped data with "mysql < file.sql", I can simply put 
"set foreign_key_checks=0;" at the beginning of the file and this works 
fine.

How can I achieve this when inserting a text file that is read with 
mysqlimport?

I tried to put the mentioned sql-statement in the txt-file, but this 
does not affect anything.

Background:
One of my developers accidently dropped a table yesterday which had to 
be re-created from a dump.
I was sort of lucky as the table was in a not too large database, so I 
could just open the dumpfile of that database and get the lines I needed 
to recreate the table and data.
If I imagine this happened on a larger database which results in 
several-GB-size dumpfiles, it would have taken MUCH longer to get that 
table back.
So now I'm playing with "mysqldump --tab" which gives nice per-table 
data and structure files.

So if there's any other well-known solution for per-table dumpfiles, let 
me know. I'm not too keen on writing something myself right now.

Thanks for your help.
Dominik
Thread
How to disable foreign_key_checks when using mysqlimport?Dominik Klein20 Jul
  • Re: How to disable foreign_key_checks when using mysqlimport?Chris White20 Jul
    • Re: How to disable foreign_key_checks when using mysqlimport?Dominik Klein21 Jul
  • Re: How to disable foreign_key_checks when using mysqlimport?Gabriel PREDA20 Jul
    • Re: How to disable foreign_key_checks when using mysqlimport?Dominik Klein21 Jul