You will need to place the following at the head of your dump file.

SET FOREIGN_KEY_CHECKS=0

-----Original Message-----
From: sean peters [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 10:28 AM
To: [EMAIL PROTECTED]
Subject: mysqldump table order with foreign keys


Hey all, 

I'm trying to dump the structure of a database using:

mysqldump -d myDatabase > structure.sql

Which works fine in getting the table create statements, but, how do i get 
mysqldump to put the creates in an order that will allow replication with 
foreign key concerns.

For instance if i have tables as follow:
CREATE TABLE Parent (
        Parent_ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
        ...
)Type= InnoDB;

CREATE TABLE Child (
        Child_ID ...,
        Parent_ID INT NOT NULL,
        ...
        FOREIGN KEY (Parent_ID) REFERENCES Parent (Parent_ID) ON DELETE
CASCADE
)Type=InnoDB;

Etc.

Mysqldump may dump the create statement for table Child before dumping the 
create statement for Parent. Then, when re-creating the database, i get 
errors, because the create for table Child references the foreign key in the

table parent, which has not yet been created.

I swear that i've seen a solution to this somewhere, but for the life of me
i 
have not been able to find the answer (now that i need it)

Thanks much,
sean peters
[EMAIL PROTECTED]

filter fodder: mysql, query


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

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

Reply via email to