Last active
July 25, 2022 15:59
-
-
Save rsperl/0247d43565e22cb62d30ca15e14957b3 to your computer and use it in GitHub Desktop.
use comments to show table and column documentation #mysql #snippet
This file contains hidden or 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
-- 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