List all columns in specific table in Snowflake

Query below returns a list of all columns in a specific table in Snowflake 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_schema ilike 'schema' -- put your schema name here
       and table_name ilike 'table'  -- put your table name here
order by ordinal_position;

Columns

  • position - column position in table, starting at 1
  • column_name - name of the column
  • data_type - data type of the column
  • max_length - data type max length
  • is_nullable - if column is nullable then YES, else NO
  • column_default - default value 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.

See live HTML data dictionary sample

Try for free