Get column name length distribution in Db2 database

Query below returns distribution of column name lengths (number of characters).


select length(c.colname) as column_name_length,
       count(*) as columns,
       count(distinct c.tabschema concat '.' concat c.tabname) as tables 
from syscat.columns c
inner join syscat.tables t on 
      t.tabschema = c.tabschema and t.tabname = c.tabname
where t.type = 'T'
and t.tabschema not like 'SYS%'
group by length(c.colname)
order by length(c.colname);


  • column_name_length - lenght in characters of column name
  • columns - number of columns with this length
  • tables - number of tables that have columns with this name length


  • One row represents one name lenght (number of characters)
  • Scope of rows: each column length that exists in a database
  • Ordered by length ascending (from 1 to max)

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.