Does a table like user_tables (used in oracle) in db2 exist?

517 views Asked by At

I know that syscat.tables exists in db2. I also tried to find the count in user_tables and I got the output this way:

db2 =>  select count(*) from user_tables

1
-----------
        999

  1 record(s) selected.

but I couldn't describe the table user_tables while I could describe any other table.

Example:

db2 => describe table user_tables

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------

  0 record(s) selected.

SQL0100W  No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table.  SQLSTATE=02000

Could you help me understand why this is happening?

2

There are 2 answers

0
data_henrik On BEST ANSWER

DB2 has an Oracle compatibility mode which needs to be enabled for a database. As part of this users can opt to have Oracle data dictionary-compatible views created. One of the views is user_tables.

Could you try the following (not tested):

describe select * from user_tables

This should return the schema for the result table which is that view.

0
AudioBubble On

SELECT * FROM systables WHERE SYSTEM_TABLE_SCHEMA ='YOURSCHEMA'