Re: How to export if I have foreign keys?
Posted by: Umesh Shastry
Date: May 13, 2005 06:17AM

Hi!

(Donno whether this procedure is advisible or not..but I used tis before for my stuff & worked fine for me..)

{FromDocs]

To make it easier to reload dump files for tables that have foreign key relationships, mysqldump automatically includes a statement in the dump output to set FOREIGN_KEY_CHECKS to 0 as of MySQL 4.1.1. This avoids problems with tables having to be reloaded in a particular order when the dump is reloaded. For earlier versions, you can disable the variable manually within mysql when loading the dump file like this:

mysql> SET FOREIGN_KEY_CHECKS = 0;
mysql> SOURCE dump_file_name
or simply
mysql db_name < script.sql

mysql> SET FOREIGN_KEY_CHECKS = 1;

This allows you to import the tables in any order if the dump file contains tables that are not correctly ordered for foreign keys. It also speeds up the import operation. FOREIGN_KEY_CHECKS is available starting from MySQL 3.23.52 and 4.0.3.

Setting FOREIGN_KEY_CHECKS to 0 can also be useful for ignoring foreign key constraints during LOAD DATA or ALTER TABLE operations.



Hope this helps!

Regards,
Umesh Shastry
http://www.blogger.com/profile/02551756983528645221

Options: ReplyQuote


Subject
Written By
Posted
Re: How to export if I have foreign keys?
May 13, 2005 06:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.