× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 11/18/2015 6:10 PM, Rob wrote:

So I have a list of all Schemas... and I used this query:
SELECT TABLE_SCHEM FROM SYSIBM.SQLSCHEMAS

But when I try to get a list of Tables for a Schema... I get NO JOY!

I have tried:
SELECT TABLE_NAME FROM SYSTABLES WHERE TABLE_SCHEMA = schema_name
SELECT TABLE_NAME FROM SYSTABLES
SELECT * FROM SYSIBM.SYSTABLES WHERE OWNER = 'MySchema' AND TYPE = 'T'
SELECT TABLE_NAME FROM MySCHEMA.SYSTABLES

The canonical reference for DB2 for i is in the Knowledge Center. Here
is the 7.2 link:
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzahg/ic-homepage.htm

From there, the 'DB2 for i SQL reference' may be useful:
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzintro.htm

From there, the 'DB2 for i catalog views' link may help:

I personally tend to use the IBM i versions, but I don't need to be
cross-platform and can afford that luxury. One thing you must be
careful of is the case of the variable contents; all of the system_
names are in upper case. You may need to uppercase user input in order
to get a match on the WHERE clause.

Also, other platforms tend to have just one schema, and that schema is
named the same as the user who created it. On IBM i, we tend to have
many schemas (libraries), and none of them are named for the user who
created them.

I'm going to second Chuck's suggestion that you consider MIDRANGE-L
rather than WEB400-L for further exploration of DB2. There is a much
wider pool of readers over there...

Nothing Works!

Thank you for providing examples of things you've tried. I notice that
some have typos. I'm going to assume this is a transcription issue, and
that you're actually submitting working SQL statements. Be sure you
have the case correct in the WHERE clause! The following work as
expected on IBM i 7.2:

-- what schemas/libraries are on the system?
select * from sysschemas order by schema_name

-- what tables are in my test library?
select table_name from systables where table_schema='BUCK'

-- what columns are in my demo file?
select column_name, data_type, length, numeric_scale
from syscolumns
where table_name = 'DATESAMPLE'
and table_schema = 'BUCK'
SELECT statement run complete.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.