Find all XML data columns in Db2 database

The query below lists all columns with XML data types in IBM Db2 database.

Query

select c.tabschema as schema_name,
       c.tabname as table_name,
       c.colno as column_id,
       c.colname as column_name,
       c.typename as data_type
from syscat.columns c
join syscat.tables t on c.tabschema = t.tabschema
                     and c.tabname = t.tabname
                     and t.type = 'T'
where c.typename = 'XML'
      and c.tabschema not like 'SYS%'
order by schema_name,
         table_name,
         column_id;

Columns

  • schema_name - name of the database (schema)
  • table_name - name of the table
  • column_id - column position in table
  • column_name - name of the column
  • data_type - type of data

Rows

  • One row represents one column with a XML data type
  • Scope of rows: all columns containing XML data types in the database
  • Ordered by schema name, table name and column position in table

Sample results