MYSQL Big DB importing via MySQL Workbench is giving error , importing in wrong orde
Hello , I have a question , I have a BIG database to import via Mysql Work bench . I am using MYSQL 5.7 , I am trying to import my database via workbanch ,but is giving error of raletad ID , it is not importing on right order .
It shoud import first -
STATE TABLE
CITY TABLE ( with state_id )
but is importing city table before state table, so it is giving error , becose city table has state_id .
I have to import all the columns that comes first ( STATE TABLE ), after import those columns that comes after (CITY TABLE) .
IT is giving me a lot of problem this .Does this happened with some one ?
Does some one know what to do ?
Thanks
Do your db tables actually have foreign keys defined?
I mean like:
state_id int not null,
FOREIGN KEY fk_state_id(state_id)
REFERENCES states(id)
ON UPDATE CASCADE
ON DELETE RESTRICT
instead of just
state_id int not null,
If you don't have true fk's set up, I believe that's your problem. Most backup programs check the foreign keys so it can put the data in the proper order, like it would know it needs to create states before cities.