Created
July 28, 2020 14:24
-
-
Save michabbb/f276153111da00932b75a04d6a9f2d78 to your computer and use it in GitHub Desktop.
Helper SELECT: Changing FLOAT to DECIMAL in MySQL
This file contains 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 | |
CONCAT('ALTER TABLE `',c.TABLE_NAME,'` CHANGE COLUMN `',c.COLUMN_NAME,'` `',c.COLUMN_NAME,'` ',REPLACE(c.COLUMN_TYPE,'float','decimal'),' ',IF(c.COLUMN_DEFAULT='NULL','DEFAULT NULL',' NOT NULL'),';') | |
FROM information_schema.COLUMNS c | |
WHERE c.TABLE_SCHEMA = 'mydatabase' | |
AND c.COLUMN_TYPE LIKE 'float%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment