Skip to content

Instantly share code, notes, and snippets.

@xyzulu
Last active March 12, 2025 03:09
Show Gist options
  • Save xyzulu/1cfcc05c57167e07f829bd20206e1f8c to your computer and use it in GitHub Desktop.
Save xyzulu/1cfcc05c57167e07f829bd20206e1f8c to your computer and use it in GitHub Desktop.
Find all MyISAM database tables and output the .sql needed to convert them to InnoDB
# You will need to login to mysql/mariadb (possibly as root user, or a user with access to all databases) first, usually: mysql
SELECT CONCAT('ALTER TABLE ',TABLE_SCHEMA,'.', table_name, ' ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables
WHERE TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema', 'innodb', 'sys', 'tmp')
AND ENGINE = 'MyISAM'
AND TABLE_TYPE = 'BASE TABLE'
ORDER BY TABLE_SCHEMA, table_name DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment