Search code examples
sqldatabasedb2db2-luw

How to find dependent materialized query table


Is there a simple way to find out which materialized query tables use my table say mytable.

As i could not alter the table because it is a base table for a materialized query table.


Solution

  • This could be queried via the System Catalog like this:

    select TABSCHEMA, TABNAME
      from syscat.tabdep
     where DTYPE = 'S'
       and BSCHEMA = 'DB2INST1' 
       and BNAME = 'EMPLOYEE'
    

    More details about the columns can be found here.