Skip to content

Instantly share code, notes, and snippets.

@michahell
Last active September 28, 2015 11:33
Show Gist options
  • Save michahell/10a49c59397731931e9e to your computer and use it in GitHub Desktop.
Save michahell/10a49c59397731931e9e to your computer and use it in GitHub Desktop.
MySQL SHOW databases alias

If you ever need to execute the following SQL statement in MySQL:

SHOW databases; or especially SHOW databases LIKE 'somePrefix_%'; and you want to alias or name the returned dataset, you can't do that with the SHOW statements as they are very limited. You can however do this if you make use of the INFORMATION_SCHEMA default MySQL table:

SELECT SCHEMA_NAME AS `Database` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'somePrefix_%';

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment