Query below returns a list of all columns in a specific table in Amazon Redshift database.
Query
select 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_name = 'table_name' -- enter table name here
-- and table_schema = 'Schema name'
order by ordinal_position;
Columns
- position - column position in table, starting at 1
- column_name - name of a column in a table
- data_type - column data type
- max_length - data type max length
- is_nullable - if column is nullable then YES, else NO
- column_default - default expression of the column
Rows
- One row represents a single column
- Scope of rows: represent all columns in a named table
- Ordered by column's ordinal position
Sample results
You could also get this
Get this interactive HTML data dictionary in minutes with Dataedo.