Modifying tables from MyISAM to InnoDB one at a time can be tedious. The following article provides a comprehensive solution to quickly convert all MyISAM tables in a database to InnoDB using SQL.
To achieve this bulk conversion, execute the following SQL statement:
SET @DATABASE_NAME = 'name_of_your_db'; SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements FROM information_schema.tables AS tb WHERE table_schema = @DATABASE_NAME AND `ENGINE` = 'MyISAM' AND `TABLE_TYPE` = 'BASE TABLE' ORDER BY table_name DESC;
Make sure to replace name_of_your_db with the name of your database.
After running the SQL statement above, the output will provide a list of SQL statements that convert each MyISAM table to InnoDB. Copy these statements into a new SQL query window and execute them. This will execute the conversion for all MyISAM tables in your database.
InnoDB offers several advantages over MyISAM, including:
The above is the detailed content of How Can I Bulk Convert All MyISAM Tables to InnoDB in MySQL?. For more information, please follow other related articles on the PHP Chinese website!