DCL commands: Grant, Revoke

26/10/2022 0 By indiafreenotes

Data Controlling Language (DCL) helps users to retrieve and modify the data stored in the database with some specified queries. Grant and Revoke belong to these types of commands of the Data controlling Language. DCL is a component of SQL commands.


SQL Grant command is specifically used to provide privileges to database objects for a user. This command also allows users to grant permissions to other users too.


grant privilege_name on object_name

to {user_name | public | role_name}

Here privilege_name is which permission has to be granted, object_name is the name of the database object, user_name is the user to which access should be provided, the public is used to permit access to all the users.


Revoke command withdraw user privileges on database objects if any granted. It does operations opposite to the Grant command. When a privilege is revoked from a particular user U, then the privileges granted to all other users by user U will be revoked.


revoke privilege_name on object_name

from {user_name | public | role_name}