List tables with the largest number of columns in Db2 database

Query that returns tables with number of columns, ordered from the ones that have the most.

Query

select 
    tabschema concat '.' concat tabname as table_name, 
    colcount as columns
from syscat.tables
where type = 'T'
order by colcount desc

Columns

  • table - name of the table (with schema name)
  • columns - number of columns in table

Rows

  • One row represents one table in a database
  • Ordered by number of columns descending - from tables with the most columns

Sample results

0
There are no comments. Click here to write the first comment.