Skip to content

Instantly share code, notes, and snippets.

@guoweihua1982
Created July 10, 2019 06:00
Show Gist options
  • Save guoweihua1982/289bc62565a186407ae0ae15e9431824 to your computer and use it in GitHub Desktop.
Save guoweihua1982/289bc62565a186407ae0ae15e9431824 to your computer and use it in GitHub Desktop.
Useful PostgreSQL SQL
-- show all tables and columns and type definitions
SELECT s.schemaname,s.relname,a.attname,format_type(a.atttypid, a.atttypmod)
FROM pg_attribute a
INNER JOIN pg_stat_user_tables s ON s.relid = a.attrelid
WHERE a.attnum > 0
ORDER BY 1,2,3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment