Could you explain more what you mean by "access schema?" Do you want to find the schema name? Do you want to access the data in a particular schema?
Joined: May 07, 2007
Hi I have created all my databse inABC schema.
I made connection to db2 databse using code .
but when try to execute any query using statement .It is refering to table or procs that are in my default schema. To solve this problem I have to prepend ABC. when I am executing any table or procs from my code. Other wise using statement object i have to execute command set current schema =ABC. But this both the two approch are not useful for me .
I want any approch such that it will refer to ABC schema.
waiting for reply Shrikant
Joined: Jun 19, 2002
I have not tried to use that feature of JDBC, but here is my opinion:
In DB2 schema is also your ID in the database. I would doubt that DB2 will let you sign on and then change the schema. Changing the schema before signing on, would serve no purpose.
I typically use the schema.objectname form of referencing database objects in DB2. So if I were doing a select from table XYZ in your example I would use the following SQL:
SELECT col1, col2 FROM ABC.XYZ;
You can also execute a command in DB2 to access another schema from your schema without using the schema prefix, but if there are objects with the same name in your schema, you will have to use the prefix to resolve the ambiguity.
The other alternative would be to login directly to the ABC schema. However, if that is a production schema, many companies restrict access to the schema.