How to provide & remove user access to/from DB2 object? Give the DB2 commands?


DB2 has a concept of DCL, through which we can control the access to DB2 objects like table, plan, etc. DCL stands for Data Control Language and using this we can provide and remove user access to the DB2 objects.

GRANT command will give the user access to the mentioned object and REVOKE command will remove the user access.

For example, if we have to provide SELECT and UPDATE access on the ORDERS table to user REL123X then we will fire below command.

GRANT SELECT, UPDATE ON ORDERS TO REL123X

If we want to provide INSERT access, then we will use the below command.

GRANT INSERT ON ORDERS TO REL123X

If we want to revoke all the access on the ORDERS table for user REL123X then we will use the below command.

REVOKE ALL ON ORDERS FROM REL123X

If we want to revoke UPDATE access on the ORDERS table for user REL123X then we will use the below command.

REVOKE UPDATE ON ORDERS FROM REL123X

If we want to revoke INSERT access on the ORDERS table for user REL123X then we will use the below command.

REVOKE INSERT ON ORDERS FROM REL123X

The important point to note here is that not all users of DB2 can execute the Data control language (DCL) GRANT and REVOKE statement. We need special DBA privileges on our userid to use DCL statements. In a real world scenario, there is a dedicated team which provides access to the database objects based on the roles assigned to the individuals.

Updated on: 30-Nov-2020

414 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements