List of source members in a file with SQL

nearly_lunchtime picture nearly_lunchtime · Dec 9, 2008 · Viewed 11.4k times · Source

Is it possible to generate a list of all source members within an iSeries source file using SQL?

Might be similar to getting table definitions from SYSTABLES and SYSCOLUMNS, but I'm unable to find anything so far.

Answer

John Y picture John Y · Jan 21, 2016

More tables and views have been added to the system catalog since the other answers were presented. Now, you can get the list of members (a.k.a. "partitions" in SQL parlance) for a given file (a.k.a. table) like this:

SELECT TABLE_PARTITION FROM SYSPARTITIONSTAT
WHERE TABLE_NAME = myfile AND TABLE_SCHEMA = mylib

You can also get other information from SYSPARTITIONSTAT such as the number of rows in each member, and timestamps for the last change, save, restore, or use.