Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dcl
communitycreator

What are the grant and revoke commands of DCL?

ACHONWA ALVAN

Data control language is a database package that helps users control access to the data in a database. It carries out the function of authorization in the database before granting access to the stored data. Two known commands for this function in the data control language are the grant and revoke commands.

The grant command

The grant command is used by users to provide privileges to database objects and to provide permission to other users.

A privilege gives permission to access a named object. For example, permission to access a database table. Users who obtain privileges can gain a connection to the database. It grants users permission to access objects of a database and administers access rights to users.

Here is how you grant privileges in SQL:

grant privilege_name on object_name
to {user_name | public | role_name}
  • object_name: Name of database object
  • privilege_name: Permission has to be granted
  • user_name: User that obtains access
  • public: Used to provide access to all users

The revoke command

The revoke command functions as the opposite of the grant command. It is used to remove the privileges on user accounts for access to a database object. It revokes permission granted to a user on a database object and also revokes the access rights assigned to users.

revoke privilege_name on object_name
from {user_name | public | role_name}

Here, the revoke command removes every privilege initially granted to the user.

Both the grant and revoke commands in a data control language help assign and deny permission to users on a database object.

RELATED TAGS

dcl
communitycreator
RELATED COURSES

View all Courses

Keep Exploring