Posted on Tuesday, 17th March 2009 by Balazs

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
  • LinkedIn
  • Facebook
  • FriendFeed
  • Twitter
  • Digg
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • Slashdot
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • RSS
  • Ping.fm
  • email
  • PDF

Tags: ,
Posted in DB2 | Comments (Comments)

blog comments powered by Disqus