Skip to content

Instantly share code, notes, and snippets.

@fabiojwalter
Created August 4, 2020 17:17
Show Gist options
  • Save fabiojwalter/95823c171fb9b59d687c240351f17f2f to your computer and use it in GitHub Desktop.
Save fabiojwalter/95823c171fb9b59d687c240351f17f2f to your computer and use it in GitHub Desktop.
SQL Query - List PostgreSQL tables per schema
select table_schema,
table_name,
ordinal_position as position,
column_name,
data_type,
case when character_maximum_length is not null
then character_maximum_length
else numeric_precision end as max_length,
is_nullable,
column_default as default_value
from information_schema.columns
where table_schema in ('public')
order by table_schema,
table_name,
ordinal_position;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment