DB2 Query to retrieve all table names for a given schema

后端 未结 13 2226
难免孤独
难免孤独 2020-12-04 17:01

I\'m just looking for a simple query to select all the table names for a given schema.

For example, our DB has over 100 tables and I need to find any table that cont

13条回答
  •  盖世英雄少女心
    2020-12-04 17:19

    select * from sysibm.systables
    where owner = 'SCHEMA'
    and name like '%CUR%'
    and type = 'T';
    

    This will give you all the tables with CUR in them in the SCHEMA schema.

    See here for more details on the SYSIBM.SYSTABLES table. If you have a look at the navigation pane on the left, you can get all sorts of wonderful DB2 metatdata.

    Note that this link is for the mainframe DB2/z. DB2/LUW (the Linux/UNIX/Windows one) has slightly different columns. For that, I believe you want the CREATOR column.

    In any case, you should examine the IBM docs for your specific variant. The table name almost certainly won't change however, so just look up SYSIBM.SYSTABLES for the details.

提交回复
热议问题