In my post "When I became victim of MySQL InnoDB/MyISAM conflict...", I wrote about the problem I am facing with the table engine unexpected changes. I also wrote about the alternative that I planned.
To resolve the issue, I renamed my old table and created a new one based on the old structure. For this I used query:
CREATE TABLE billitems SELECT * FROM billitems_old;
Secondly, I wanted to transfer all the records from the old table to the new one.I wanted to keep inserting rows without aborting on any errors. Thanks to "Shylent", a poster in a forum for suggesting this solution:
insert ignore into billitems select * from billitems_old;
I attempted this code but, because of some reasons, MySQL still generated error:
Cannot add or update a child row: a foreign key constraint fails (stockist.billitems, CONSTRAINT FK_billitems_1 FOREIGN KEY (BillNo, BillDate) REFERENCES billdetails (BillNo, BillDate) ON DELETE CASCADE ON UPDATE CASCADE)
MySQL was still not ignoring errors. U.Shastry suggested this solution and it worked:
SET foreign_key_checks = 0;
insert ignore into billitems select * from billitems_old;
SET foreign_key_checks = 1;
Comments