Skip to content

Instantly share code, notes, and snippets.

@cchng
Last active August 15, 2018 04:25
Show Gist options
  • Select an option

  • Save cchng/8d1f12dd7b9e96a13a266e0e32734cff to your computer and use it in GitHub Desktop.

Select an option

Save cchng/8d1f12dd7b9e96a13a266e0e32734cff to your computer and use it in GitHub Desktop.
a query for useful information on your data in a specified schema
-- https://stackoverflow.com/questions/343138/retrieving-comments-from-a-postgresql-db
SELECT col.table_name,col.column_name, pgd.description, col.data_type
FROM pg_catalog.pg_statio_all_tables AS st
INNER JOIN pg_catalog.pg_description pgd ON (pgd.objoid=st.relid)
INNER JOIN information_schema.columns col ON (pgd.objsubid=col.ordinal_position
AND col.table_schema=st.schemaname AND col.table_name=st.relname)
WHERE col.table_schema = $schema_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment