Menu & Search
List all Schemas/Tables/Columns in RedShift & Postgres

List all Schemas/Tables/Columns in RedShift & Postgres

This script returns all schemas, tables and columns within RedShift or Postgres.

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
order by table_schema, table_name, ordinal_position;

Filter out system schemas (information_schema & pg_catalog) with a WHERE clause if you want to see schema & tables created by users.


Share

0 Comments