Search code examples
c#db2odbcibm-midrange

Enumerate tables in iSeries DB2 from C#/ODBC


I need to enumerate all tables (by that I mean get a list of schema and table name strings) and views in an iSeries DB2 database (I believe version 7, but I could be wrong) for which I have an ODBC connection. I tried:

show tables
select * from syscat.tables

However, the server responds with unknown command for show tables and unknown table for select respectively:

ERROR [42S02] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 - TABLES in SYSCAT type *FILE not found

I know that it is somehow possible to enumerate tables because Visual Studio does it from the Server Explorer. I am probably overlooking something very obvious but I am not really versed in ODBC. Thanks.


Solution

  • According to the manual, you probably want to use something like

    select table_name from sysibm.sqltables