At 20:36 -0700 on 06/02/2004, David Blomstrom wrote about Exporting/Importing Databases:

Third, my practice database includes half a dozen
tables, but only one made it online, followed by this
error message:

Database USERNAME  running on localhost

Error

SQL-query :

CREATE TABLE `counties` (
`SCode` varchar( 6 ) NOT NULL default '',
`NameC` varchar( 255 ) default NULL ,
`TypeC` varchar( 255 ) default NULL ,
`Seat` varchar( 255 ) default NULL ,
`Area_MI` decimal( 10, 1 ) default NULL ,
`Area_KM` decimal( 10, 1 ) default NULL ,
`Pop_2000` int( 10 ) default NULL ,
`Pop_1990` int( 10 ) default NULL ,
`Pop_MI` decimal( 10, 1 ) default NULL ,
`Pop_KM` decimal( 10, 1 ) default NULL ,
`Race1` int( 10 ) default NULL ,
`Race2` int( 10 ) default NULL ,
`Amerindian` int( 10 ) default NULL ,
`White` int( 10 ) default NULL ,
`Black` int( 10 ) default NULL ,
`Asian` int( 10 ) default NULL ,
`Pacific_Island` int( 6 ) default NULL ,
`Some_Other_Race` int( 10 ) default NULL ,
`Hispanic` int( 10 ) default NULL ,
`id` int( 6 ) NOT NULL AUTO_INCREMENT ,
PRIMARY KEY ( `id` ) ,
KEY `SCode` ( `SCode` ) ,
CONSTRAINT `0_132` FOREIGN KEY ( `SCode` ) REFERENCES
`statesarticles` ( `SCode` ) ON UPDATE CASCADE
) TYPE = InnoDB AUTO_INCREMENT =3143

MySQL said:
#1005 - Can't create table './[USERNAME]/counties.frm'
(errno: 150)

Do you know what this means?

You just got caught with the old Referential Integrity Gotcha. It will not allow you to create countries since statesarticles does not (yet) exist.


The fix is to temporally turn off RI during the load. Put this command at the start of your file:

SET FOREIGN_KEY_CHECKS = 0;

and this one at the end:

SET FOREIGN_KEY_CHECKS = 1;

and it will work.

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



Reply via email to