DB2 List of Tables

To retrieve to list of tables in DB2, you need to use the system tables, and then a little bit of sed.  Here is how it goes:

db2 "SELECT tabschema || '.' || tabname FROM syscat.tables" | sed -e '/ //g'

You can redirect this into a file, and you may need to cut off the first few and last few lines.  If you only want to get the tables from a given user space:

SELECT tabschema || '.' || tabname FROM syscat.tables WHERE tbspace = 'USERSPACE1';

If you want the list for a specific schema:

SELECT tabschema || '.' || tabname FROM syscat.tables WHERE tabschema = 'MYSCHEMA';

Reference: How to get useful information from the DB2 UDB system catalog

This entry was posted in DB2 and tagged , . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.