You are viewing...

Generate SQL queries to update collations for all tables in a DB

Updated on March 03, 2018 at the 15th hour
Posted under:

DISCLAIMER: All views are considered my own and you should not draw any conclusions on associates.

Found this gem on another website:

SELECT CONCAT('ALTER TABLE ', tbl.TABLE_SCHEMA, '.', tbl.TABLE_NAME, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;') FROM information_schema.TABLES tbl WHERE tbl.TABLE_SCHEMA = '<TABLENAME>';


This query will generate sql statements to alter all tables in a MySQL db to utf8mb4 collation.

You just read "Generate SQL queries to update collations for all tables in a DB". Please share if you liked it!
You can read more recent posts here.