views:

19

answers:

1

I want to convert the db with innodb tables into myisam, all of them. How can I do these? there are some foreign keys exist among tables.

how can I make this in the best way?

A: 

You can't convert directly from InnoDB to MyISAM while the foreign keys are still there. You have to remove the constraints first. To do this, for each table follow these steps:

  1. Issue SHOW CREATE TABLE tablename
  2. For each CONSTRAINT ... FOREIGN KEY declaration in the output, you will need to issue ALTER TABLE tablename DROP FOREIGN KEY x where x is the identifier that appears between CONSTRAINT and FOREIGN KEY.
  3. Issue SHOW CREATE TABLE tablename again. The foreign key constraints may have left behind indexes (since InnoDB requires an index on each foreign key, and it won't necessarily remove them just because you have removed the constraint). For each index you decide you no longer want, issue ALTER TABLE tablename DROP INDEX indexname.

Once you have done this for all tables that are involved with constraints, you can convert tables to MyISAM individually using ALTER TABLE tablename ENGINE=MYISAM.

Hammerite
Another thing that just occurred to me: You can do more than one thing with a given ALTER TABLE command, so the following would be valid: ALTER TABLE tablename DROP FOREIGN KEY x1, DROP FOREIGN KEY x2, ..., DROP FOREIGN KEY xn
Hammerite
thank you very much, really helps me a lot!
Joe