Curriculum
Course: SQL-100-Queries-Solutions
Login
Text lesson

DCL(Data Control Language) Commands

DCL(Data Control Language) Commands

(Out of the syllabus Class- XII)

DCL

Data Control Language

GRANT, REVOKE

GRANT and REVOKE Commands in SQL

In SQL, GRANT and REVOKE are DCL (Data Control Language) commands. They are used to control user access and permissions on database objects like tables, views, and procedures.

 

1. GRANT Command

Purpose

The GRANT command is used to give privileges (permissions) to a user or role.

Syntax

 
GRANT privilege_name
ON object_name
TO user_name;

Common Privileges

  • SELECT – Read data

  • INSERT – Add new records

  • UPDATE – Modify existing data

  • DELETE – Remove records

  • ALL – All privileges

Example

 
GRANT SELECT, INSERT
ON student
TO user1;

Allows user1 to read and insert data into the student table.

Grant with Admin Option

 
GRANT SELECT
ON student
TO user1
WITH GRANT OPTION;

User1 can now grant this privilege to other users.

 

2. REVOKE Command

Purpose

The REVOKE command is used to remove previously granted privileges from a user or role.

Syntax

 
REVOKE privilege_name
ON object_name
FROM user_name;

Example

 
REVOKE INSERT
ON student
FROM user1;

Removes the INSERT permission from user1 on the student table.

 

GRANT vs REVOKE (Quick Comparison)

 

Feature GRANT REVOKE
Command Type DCL DCL
Function Gives permission Removes permission
Access Control Allows access Restricts access
Usage Security management Security management
Scroll to Top