Created
October 20, 2017 20:10
-
-
Save bitlather/02e7e5c9950b60ece69ebc15be2aef06 to your computer and use it in GitHub Desktop.
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
-- PostgreSQL 9.3.14 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit | |
-- ============================================================================ | |
-- Create a view to easily read table comments. | |
-- | |
-- Returns: | |
-- | |
-- A list of table names and comments associated with them. | |
-- | |
-- Usage: | |
-- | |
-- SELECT * FROM table_documentation; | |
-- | |
-- ============================================================================ | |
CREATE OR REPLACE VIEW table_documentation AS | |
SELECT | |
CAST(c.relname AS TEXT) AS table_name, | |
CAST(d.description AS TEXT) AS comment | |
FROM pg_class AS c | |
LEFT JOIN pg_description AS d ON (d.objoid = c.oid AND d.objsubid = 0) | |
WHERE c.relkind IN('r', 'v') AND d.description > '' | |
ORDER BY c.relname; | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment