Created
August 28, 2012 15:08
-
-
Save erkattak/3498909 to your computer and use it in GitHub Desktop.
Get all queries to convert base tables in a given database to specific character set and collation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
DISTINCT CONCAT( | |
'ALTER TABLE `', | |
`COLUMNS`.`TABLE_SCHEMA`, | |
'`.`', | |
`COLUMNS`.`TABLE_NAME`, | |
'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;' | |
) | |
FROM | |
`information_schema`.`COLUMNS` | |
JOIN | |
`information_schema`.`TABLES` ON | |
`TABLES`.`TABLE_SCHEMA` = `COLUMNS`.`TABLE_SCHEMA` | |
AND | |
`TABLES`.`TABLE_NAME` = `COLUMNS`.`TABLE_NAME` | |
WHERE | |
`COLUMNS`.`TABLE_SCHEMA` = '471712_yah10' | |
AND | |
( | |
`COLUMNS`.`COLLATION_NAME` IS NOT NULL | |
AND | |
`COLUMNS`.`COLLATION_NAME` NOT LIKE 'utf8_uni%' | |
) | |
AND | |
`TABLES`.`TABLE_TYPE` = 'BASE TABLE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment