📘 What is DCL (Data Control Language)?
DCL (Data Control Language) is a subset of SQL used to control access to data in a database.
If SQL were a building, DCL would be the security system — determining who gets in, what they can do, and whether they can touch anything sensitive.
🧩 Role of DCL in SQL:
SQL is divided into several sub-languages:
| Type | Purpose | Examples |
|---|---|---|
| DDL | Define structure | CREATE, ALTER |
| DML | Manage data | SELECT, INSERT, UPDATE, DELETE |
| DCL | Control access | GRANT, REVOKE |
| TCL | Manage transactions | COMMIT, ROLLBACK |
So, DCL = security & permissions layer of SQL.
🔐 Key DCL Commands:
1. GRANT
Gives a user specific privileges on a database object.
GRANT SELECT, INSERT ON customers TO gaurav;Gives user
gauravpermission toSELECTandINSERTinto thecustomerstable.
2. REVOKE
Removes previously granted permissions.
REVOKE INSERT ON customers FROM gaurav;Takes away the
INSERTpermission fromgauravon thecustomerstable.
🛡️ Why DCL Matters:
| Scenario | DCL Usage Example |
|---|---|
| Limit access for junior devs | Only allow SELECT, not DELETE |
| Secure sensitive tables | HR salary table → only HR team gets access |
| Handle third-party integrations | Grant limited access to APIs or analytics tools |
⚠️ DCL is not transactional (usually)
-
In most DBMS systems,
GRANTandREVOKEare immediate and auto-committed. -
That means you can’t rollback a
GRANTif it goes wrong.
🧠 Interview Line:
“DCL is the part of SQL that handles permissions using
GRANTandREVOKEto control who can access or modify database objects.”