Skip to content

Instantly share code, notes, and snippets.

@rsperl
Last active July 25, 2022 15:59
Show Gist options
  • Save rsperl/0247d43565e22cb62d30ca15e14957b3 to your computer and use it in GitHub Desktop.
Save rsperl/0247d43565e22cb62d30ca15e14957b3 to your computer and use it in GitHub Desktop.
use comments to show table and column documentation #mysql #snippet
-- table documentation
SELECT t.TABLE_SCHEMA, t.TABLE_NAME, t.TABLE_COMMENT
FROM TABLES t
WHERE t.TABLE_SCHEMA not in ('information_schema', 'mysql')
ORDER BY t.TABLE_SCHEMA, t.TABLE_NAME;
-- column documentation
SELECT c.TABLE_SCHEMA, c.TABLE_NAME, c.COLUMN_NAME, c.COLUMN_DEFAULT, c.COLUMN_TYPE, c.COLUMN_COMMENT
FROM information_schema.COLUMNS c
WHERE
c.TABLE_SCHEMA not in ('information_schema', 'mysql')
-- and c.TABLE_NAME='t'
ORDER BY c.TABLE_SCHEMA, c.TABLE_NAME, c.ORDINAL_POSITION;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment