Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing storage engine of table in Mysql

Tags:

mysql

Currently the storage type of table is innodb , i want to add full text search on the table which is only possible on MYISAM engine. I tried using the command => alter table film engine = myisam; and got the error:

1217 - Cannot delete or update a parent row: a foreign key constraint fails

Help Please!! Thanks.

like image 936
Ravi Jain Avatar asked Feb 04 '12 09:02

Ravi Jain


1 Answers

You must find the tables in the database that refer to this table through a FK constraint:

Identify the foreign key constraints for the table. Either use

SHOW CREATE TABLE `table_in_db_film`\G;

or

USE db_of_film_table;
SHOW TABLE STATUS LIKE 'film'\G

afterwards execute the necessary statements

ALTER TABLE film DROP FOREIGN KEY `ibfk_something`;

until you drop all constraints (of course replace ibfk_something with your constraint names). After this you should be able to alter the table engine.

like image 120
georgepsarakis Avatar answered Oct 09 '22 23:10

georgepsarakis