At the point when numerous clients can get to database objects, endorsement can be restrained to these items with benefits. Each article has a proprietor. The DB2 Privileges handles if a client can alter an article claimed by another client.
Granted and revoked are the DB2 Privileges that the administrator provides to the users. A DB2 Privileges are the authorities to assassinate a specific sort of SQL explanation that get to another client's objects. A few sets of benefits incorporate the DB2 Privileges to :
Interface with the database
Constitutes a database or a table
Table can be altered
Preferred lines from another client's table
Performs stored method of another client.
Types of DB2 Privileges
Description
DB2 Privileges can be classified into 2 types:
Grant
Revoke
Conceptual
figure
Grant
Description
GRANT proclamation characteristic the privileges that are accessed in the statement. These proclamations are utilized to accredit the privileges on the objects in the database.
Syntax
The syntax for Grant privilege is as follows:
Grant select on table <table_name> to privilege object
Privileges => Are the access permissions.
Object => Accessing the grant permissions.
Table name => Accurate table name in the database.
Examples
By viewing the below example, the concept of Grant privilege can be easily understand.
[c]
db2 => create user Shah with password 'shah';
SQL executed ok (0.52 sec)
db2 => select * from Emp.Employee22;
Emp_id Emp_Name Dept Age Salary
--------- --------- ----------- ----- --------
1001 John Manager 45 25000
1004 Mate Admin 50 41000
1003 Mike Database 43 40000
1005 Shah Sales 52 42000
1006 Maddie Marketing 51 22000
5 record(s) selected
db2 => Grant select on table Emp.Employee22 to Emp.Employee21
db2 => select * from Emp.Employee21;
Emp_id Emp_Name Dept Age Salary
-------- ----------- --------- ------ --------
1001 John Manager 45 25000
1004 Mate Admin 50 41000
1003 Mike Database 43 40000
1005 Shah Sales 52 42000
1006 Maddie Marketing 51 22000
5 record(s) selected
[/c]
Revoke
Description
Revoke command is utilized to dismiss all the privileges that have been assigned for a user in the database.
Syntax
The syntax for Revoke privilege is as follows:
Revoke select on table <table_name> to privilege object
Privileges => Are the access permissions.
Object => Accessing the grant permissions.
Table name => Accurate table name in the database.
Examples
By viewing the below example, the concept of Revoke privilege can be easily understand.
[c]
db2 => REVOKE ALL ON Emp.Employee21;
REVOKED
DB2 => Drop user shah;
DROP ROLE
[/c]
Revoke all the grant permissions assigned to shah and at the same time we can drop the user shah from the database.
Summary
Key Points
DB2 Privileges - Privileges are the Access permissions assigned to the users in the database.
Grant - Grants privileges to the user.
Revoke - Revoke all the grant privileges to the user.