DB2 on AS/400 (iSeries) -- How do I list databases, tables, views?

Posted on 2007-10-11
Last Modified: 2012-06-27
I am working on a tool to issue queries to DB2 on an AS/400 (iSeries) system.

Is there a way, using SQL, to:
1.  List all the databases on that instance of DB2
2.  List all the tables in a DB
3.  List all the view in a DB

Question by:Daniel Wilson
    LVL 37

    Accepted Solution

    get a list of all databases :
    i don't know if you can do that using sql

    list of tables
    select table_name from qsys2.systables where table_type='T'

    list view
    select table_name from qsys2.systables where table_type='V'
    LVL 18

    Assisted Solution


    Momi's right on the money.

    Personally, I'd add the schema to the select-list:

    select table_schema,
    from    systables    
    where  table_type='T'

    In AS/400, a database is the same thing as a schema. To get a list of all databases (a.k.a. schemas):

    select distinct table_schema
    from   systables


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now