Sample Header Ad - 728x90

Change Storage Engine on Referenced Tables

0 votes
1 answer
325 views
i need to change storage engine from 'InnoDB' to 'MyISAM' on some tables of different databases. So i made a script file to do so: #!/bin/bash DATABASES=$(mysql -u XXXXX -pXXXXX --skip-column-names -e 'select distinct(table_schema) from information_schema.tables where table_schema not in ("mysql","information_schema","performance_schema")') for D in $DATABASES do TABLES=$(mysql -u XXXXX -pXXXXX --skip-column-names -e 'select table_name from information_schema.tables where table_schema="'$D'" and engine="InnoDB"') for T in $TABLES do echo "ALTERING TABLE $T" mysql -u XXXXX -pXXXXX -e "USE $D; ALTER TABLE $T ENGINE=MYISAM" done done It works on some tables, but on those with foreign keys, displays the following error message: ERROR 1217 (23000) at line 1: Cannot delete or update a parent row: a foreign key constraint fails Is there a way to change storage engine on those tables?
Asked by kriegu (670 rep)
Feb 9, 2015, 06:47 PM
Last activity: Jul 30, 2025, 04:03 PM