Perfect ๐
Now DCL commands in the exact same pattern you liked:
Base state
Question
SQL
Result / Output (privilege table)
✔ clear takeaways
๐ Base State (Before DCL Commands)
Users & Table
User:
john_doeTable:
employees
Existing Privileges (Initially)
| User | Table | SELECT | INSERT | UPDATE | DELETE |
|---|---|---|---|---|---|
| john_doe | employees | ❌ | ❌ | ❌ | ❌ |
๐งพ Summary Table (DCL Questions)
| No. | DCL Command | Question |
|---|---|---|
| 1 | GRANT | Give SELECT & INSERT access |
| 2 | REVOKE | Remove SELECT & INSERT access |
1️⃣ GRANT
Question: Give user john_doe permission to SELECT and INSERT data from employees table.
GRANT SELECT, INSERT
ON employees
TO john_doe;
✅ Result (Privileges AFTER GRANT)
| User | Table | SELECT | INSERT | UPDATE | DELETE |
|---|---|---|---|---|---|
| john_doe | employees | ✅ | ✅ | ❌ | ❌ |
✔ User can read data (SELECT)
✔ User can add data (INSERT)
✔ Other actions still restricted
2️⃣ REVOKE
Question: Remove SELECT and INSERT permissions from user john_doe.
REVOKE SELECT, INSERT
ON employees
FROM john_doe;
✅ Result (Privileges AFTER REVOKE)
| User | Table | SELECT | INSERT | UPDATE | DELETE |
|---|---|---|---|---|---|
| john_doe | employees | ❌ | ❌ | ❌ | ❌ |
✔ Access removed
✔ User can no longer read or insert data
๐ฅ GRANT vs REVOKE (Exam Favorite)
| Feature | GRANT | REVOKE |
|---|---|---|
| Purpose | Give permission | Take permission |
| Affects | User / Role | User / Role |
| Data change | ❌ No | ❌ No |
| Structure change | ❌ No | ❌ No |
| Category | DCL | DCL |
๐ง One-Line Memory Trick (DCL)
| Command | Meaning |
|---|---|
| GRANT | Allow access |
| REVOKE | Remove access |
⚠️ Exam Notes (Important)
DCL commands do not modify data
Used mainly by DBA / Admin
Privileges can be given on table, view, database
If you want next:
TCL commands (COMMIT, ROLLBACK, SAVEPOINT)
Complete SQL cheat-sheet (DDL + DML + DCL + TCL)
MCQs with privilege-based output
Hindi explanation for exams
Just say ๐
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.