Skip to content

Instantly share code, notes, and snippets.

@filipeandre
Last active April 17, 2018 13:09
Show Gist options
  • Save filipeandre/1bada71a9e827ebd84b37452df70e2cd to your computer and use it in GitHub Desktop.
Save filipeandre/1bada71a9e827ebd84b37452df70e2cd to your computer and use it in GitHub Desktop.
Convert all tables to utf8_general_ci
SELECT
CONCAT( 'ALTER TABLE `', TABLE_NAME, '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) AS 'Copy & run these SQL statements:'
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA = "database_name"
AND TABLE_COLLATION != "utf8_general_ci"
AND TABLE_TYPE = "BASE TABLE";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment