📎 Referral Code:
📊 Dashboard Sign In
Navigation
🗺️
Courses
🎬
Short Videos
💡
Pro Tip Videos
Job Support
🎯
Interview Board
👥
Chat Room
AI Tools
🌐
Project Explanation Agent
🛟
Support Works
Home
SQL Introduction
SQL Data Control Language (DCL)
SQL Introduction SQL Data Control Language (DCL)
SQL Data Control Language (DCL)
SQL Introduction
20:50
Now Watching
Previous
← Previous
SQL Transaction Control Language (TCL)
Lesson Progress
🎉 Section Done!
See next section →
🎉 You've completed SQL Introduction!
Great work! Select the next lesson from the sidebar to continue your journey.
📄 View Reference Document & Notes

📋 Lesson Notes & Resources

Understanding Data Control Language (DCL) in SQL: GRANT and REVOKE Explained for Beginners

Data Control Language (DCL) in SQL is used to manage access permissions and control privileges in a database. DCL ensures that only authorized users can access specific resources or perform particular actions on the database. The two main DCL commands are GRANT and REVOKE.

1. GRANT Command

The GRANT command is used to give permissions to users to perform specific tasks on the database.

Syntax:

GRANT privilege_name ON object_name TO user_name;
    

Example: Grant SELECT permission on the Employees table to a user John:

GRANT SELECT ON Employees TO John;
    

Employees Table:

EmployeeID Name Position Salary
1 Alice Manager 100000
2 Bob Developer 80000
3 Charlie Tester 60000

2. REVOKE Command

The REVOKE command is used to remove permissions that were previously granted to a user.

Syntax:

REVOKE privilege_name ON object_name FROM user_name;
    

Example: Revoke SELECT permission on the Employees table from John:

REVOKE SELECT ON Employees FROM John;
    

Real-Life Scenario

Suppose you are managing a database for a company. Different departments (e.g., HR, Finance) need access to specific data:

  1. HR should be able to view and update employee details but not delete them.
  2. Finance should be able to view employee salaries but not update or delete them.

Grant Permissions to HR:

GRANT SELECT, UPDATE ON Employees TO HR;
    

Grant Permissions to Finance:

GRANT SELECT (Salary) ON Employees TO Finance;
    

Revoke Permissions if Needed:

REVOKE UPDATE ON Employees FROM HR;
    

Important Notes

  • Permissions can be granted to individual users or roles (groups of users).
  • The database administrator (DBA) usually manages permissions.
  • Using GRANT and REVOKE correctly ensures data security by restricting unauthorized access.
Course Content
5 lessons