Re: How to disable foreign_key_checks when using mysqlimport?

2006-07-21 Thread Dominik Klein

Gabriel PREDA schrieb:

Try:

ALTER TABLE `tbl_name` DISABLE KEYS;
-- now insert in the TXT file
ALTER TABLE `tbl_name` ENABLE KEYS;


I think this is what you were looking for !



That would have been a possibility. I did it this way now:

...
echo set sql_log_bin=0; set foreign_key_checks=0; use $db; load data 
infile \$txtfilename\ into table $tablename fields enclosed by '\';| 
$MYSQL_BIN $MYSQL_CONNECT

...

Script performs several checks before this statement and puts the 
txtfile in the appropriate directory.


Regards
Dominik

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: How to disable foreign_key_checks when using mysqlimport?

2006-07-21 Thread Dominik Klein

mysqldump -u [user] -h [host] -p [database] [table]  fixme.sql


This is for one table.

As I need it for all my tables in all my databases, I'd have to write a 
script for that.


And as --tab uses less space, I prefer --tab option for mysqldump.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: How to disable foreign_key_checks when using mysqlimport?

2006-07-20 Thread Chris White
On Thursday 20 July 2006 04:10 am, Dominik Klein wrote:
 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.

So do it that way

 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.

mysqldump -u [user] -h [host] -p [database] [table]  fixme.sql
mysql -u [user] -h [host] -p [database]  fixme.sql

and for the paranoid, you can always use the ever efficient test database to 
test things first:

mysql -u [user] -h [host] -p test  fixme.sql

 Thanks for your help.
 Dominik

-- 
Chris White
PHP Programmer/DBlankRounds
Interfuel

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: How to disable foreign_key_checks when using mysqlimport?

2006-07-20 Thread Gabriel PREDA

Try:

ALTER TABLE `tbl_name` DISABLE KEYS;
-- now insert in the TXT file
ALTER TABLE `tbl_name` ENABLE KEYS;


I think this is what you were looking for !

--
Gabriel PREDA
Senior Web Developer

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]