Question

I'm using DB2 10.5 and have two users: db2admin and db2user. db2admin is an Administrator of the Windows 7 Operating System while db2user is a normal user. I have created a database named DB1 using db2admin and now I want to allow db2user to access the TB1 table in it.

I used the following command for that:

db2 => connect to db1 user db2admin using db2admin
db2 => grant select, insert, update, delete on tb1 to user db2user

The Result when executed following commands:

connect to db1 user db2user using db2user
SELECT * FROM SYSIBMADM.PRIVILEGES WHERE AUTHID = SESSION_USER AND AUTHIDTYPE = 'U'

AUTHID     AUTHIDTYPE PRIVILEGE   GRANTABLE OBJECTNAME
DB2USER    U          UPDATE      N         TB1
DB2USER    U          SELECT      N         TB1
DB2USER    U          INSERT      N         TB1
DB2USER    U          DELETE      N         TB1

According to that result set db2user seems to have privileges to the TB1. However, when I tried to access it programmatically using db2user, following error was thrown:

DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2USER.TB1

According to the error code there is no TB1 in the DB2USER schema.

Following commands confirmed that:

connect to db1 user db2user using db2user
db2 => list tables

0 record(s) selected.

What am I missing or doing wrong? Any guidance on how to get this working is much appreciated.

UPDATE: I have already tried accessing the same table with db2admin and it works perfectly. What I want to get done is to access it using db2user, but db2user shouldn't create the tables; that's db2admin's job. So how can I get that working? How can db2admin put the tables inside db2user's schema?

Was it helpful?

Solution

SQLCODE -204 means that the object cannot be found. My guess is that since you didn't provide a schema, your table was implicitly placed in the db2admin schema. Try doing

SELECT * FROM db2admin.tb1

And see if that works.

OTHER TIPS

You created the table from user DB2ADMIN and the implicit schema will be used. In this case, the table is called db2admin.tb1

When you perform a select from the DB2USER, the implicit schema is the same user name, and that table does not exist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top