This query returns columns in a database sorted by their name length.
Query
select column_name,
length(column_name) col_length,
table_schema,
table_name
from v_catalog.columns
where table_schema in ('public2','online_sales', 'store')
order by col_length desc,
column_name;
Columns
- column_name - column name
- col_length - column name length
- table_schema - table schema name
- table_name - 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 longest to shortest) and column name