Created
March 1, 2012 14:49
-
-
Save timkeller/1950247 to your computer and use it in GitHub Desktop.
Quick generator, in sql, to create ALTER sql instructions for a set of databases of the same schema on the same MySQL server
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 `', | |
TABLE_SCHEMA, | |
'`.`', | |
TABLE_NAME, | |
'` ADD `change-field-name` VARCHAR(5) NULL DEFAULT NULL', | |
';' | |
) AS sql_string | |
FROM | |
information_schema.COLUMNS | |
WHERE | |
TABLE_SCHEMA LIKE "some-prefix-maybe_%" AND | |
TABLE_NAME = "change-table-name" | |
GROUP BY | |
TABLE_SCHEMA, | |
TABLE_NAME; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment