List table default values in Redshift

This query returns list of all columns with a default value in a specific table.

Query

select col.table_schema,
       col.table_name,
       col.column_name,
       col.column_default
from information_schema.columns col
where col.column_default is not null
      and col.table_schema not in('information_schema', 'pg_catalog')
order by col.column_name;

Columns

  • table_schema - schema name
  • table_name - table name
  • column_name - column name
  • column_default - column's default value

Rows

  • One row represents one column
  • Scope of rows: columns with a default value in a specified table
  • Ordered by column name

Sample results