This query returns columns in Snowflake database sorted by their name.
Query
select c.column_name,
length(c.column_name) as column_name_length,
t.table_schema,
t.table_name
from information_schema.tables t
inner join information_schema.columns c on
c.table_schema = t.table_schema and c.table_name = t.table_name
where table_type = 'BASE TABLE'
order by column_name_length desc,
c.column_name;
Columns
- column_name - column name
- column_name_length - column name length
- table_schema - column table schema name
- table_name - column table name
Rows
- One row represents one column of each table in a database
- Scope of rows: each column that exists in a database
- Ordered by length descrending - from longhest to shortest