Data Control Language

Suggested reading before moving to Data Control Language:

Data Control Language (DCL) is used to manage user rights in the database. It is used to manage privileges to allow user to manipulate data in database. There are two major commands in this category:

  • GRANT
  • REVOKE

Table of Contents

GRANT

The GRANT command is used to grant privilege to the user. You can grant permission to user for any operation. The syntax of command is:

GRANT SELECT, INSERT, UPDATE, DELETE ON table_name TO user_name;

For example, to grant SELECT, INSERT, UPDATE, DELETE permission to user ‘Sahil’ on table Student we can use the following commands:

GRANT SELECT, INSERT, UPDATE, DELETE ON Student TO Sahil;

This allows user Sahil to perform SELECT, INSERT, UPDATE, DELETE operations. The user Sahil cannot perform any other operation on table Student like ALTER etc.

REVOKE

The REVOKE command is used to take back the privileges already assigned to the user. The syntax of command is:

REVOKE SELECT, INSERT, UPDATE, DELETE ON table_name FROM user_name;

In our above example, we remove the privileges by using the command:

REVOKE SELECT, INSERT, UPDATE, DELETE ON Student FROM Sahil;

Download as PDF

Read next:  E-R Model ››

« Back to Course page