Skip to content

Instantly share code, notes, and snippets.

@andretw
Last active August 29, 2015 13:58
Show Gist options
  • Save andretw/10347478 to your computer and use it in GitHub Desktop.
Save andretw/10347478 to your computer and use it in GitHub Desktop.
SQL to select and change the collation from one to another. (utf8, for example.)
# ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
# ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
SELECT CONCAT("ALTER TABLE ",TABLE_SCHEMA,".",TABLE_NAME," CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;") AS alter_sql
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'cms';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment