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

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • email
  • LinkedIn
  • PDF
  • Ping.fm
  • RSS
  • Slashdot
  • Twitter
This entry was posted in DB2 and tagged , . Bookmark the permalink.

Comments are closed.

blog comments powered by Disqus