Search code examples
db2sql-grantdatabase-permissions

Altering view/access permissions for a schema in DB2


I am working around a workaround to a "feature" in IBM DB2.

This fancy database has a "feature" in it which if I try to use a CREATE TABLE statement and it doesn't find the schema, it will create this schema for me, even if I don't want it to. This bug has caused me a lot of hours in debugging, because my code right now exists with the expectation that it won't create the schema if it doesn't exist

My question is -- how do I change the permissions of a particular schema (or even during the create schema phase) which a particular user does not have access to view?

I checked out this doc..

It seems with GRANT, there are the following three permissions:

ALTERIN Grants the privilege to alter or comment on all objects in the schema. The owner of an explicitly created schema automatically receives ALTERIN privilege.

CREATEIN Grants the privilege to create objects in the schema. Other authorities or privileges required to create the object (such as CREATETAB) are still required. The owner of an explicitly created schema automatically receives CREATEIN privilege. An implicitly created schema has CREATEIN privilege automatically granted to PUBLIC.

DROPIN Grants the privilege to drop all objects in the schema. The owner of an explicitly created schema automatically receives DROPIN privilege

With only ALTERIN, CREATEIN, and DROPIN, I don't see anything relevant to view access permissions :/

EDIT:

I checked out our Dash DB database for this particular table which has these special permissions for particular users using the following SQL:

SELECT * FROM SYSIBMADM.PRIVILEGES WHERE OBJECTSCHEMA = 'FAKE_SCRATCH';

This is the result:

enter image description here

EDIT 2:

I tried the following to emulate Dash DB's permissions for that user for that schema:

GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA FAKE_SCRATCH TO USER TEST_USER;

enter image description here

Still doesn't work :/


Solution

  • The following SQL query executed in DB2 fixed the problem:

    REVOKE IMPLICIT_SCHEMA ON DATABASE FROM PUBLIC