Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active March 1, 2017 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todgru/17aa3fc93e892562d7cf42d2e7a82f6e to your computer and use it in GitHub Desktop.
Save todgru/17aa3fc93e892562d7cf42d2e7a82f6e to your computer and use it in GitHub Desktop.
Query that writes an alter table query for all tables of a certain name
SELECT concat( 'ALTER TABLE ', a.table_name, ' MODIFY field_name VARCHAR(255) NOT NULL;' )
FROM information_schema.tables a
WHERE a.table_name LIKE 'foo%bar';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment