7/2/25, 5:13 PM Advanced DB Access Protocols
GRANT SELECT, INSERT ON employee TO user1;
✅ Explanation:
This command gives user1 the ability to:
View data from the employee table (via SELECT ).
Insert new records (rows) into the employee table (via INSERT ).
🔍 What user1 can do now:
sql Copy Edit
SELECT * FROM employee; INSERT INTO employee (emp_id, name, dept, salary) VALUES (101,
'Amit', 'CS', 50000);
🚫 What user1 still can't do:
Update or delete rows from the employee table (no UPDATE or DELETE privileges yet).
2️⃣
sql Copy Edit
GRANT UPDATE (salary) ON employee TO user2;
✅ Explanation:
This command allows user2 to:
Modify (update) the value of the salary column only in the employee table.
🔍 What user2 can do now:
sql Copy Edit
UPDATE employee SET salary = 60000 WHERE emp_id = 101;
🚫 What user2 cannot do:
Update other columns like name or dept .
Select (view), insert, or delete data — unless those privileges are granted separately.
https://chatgpt.com/c/6864b7be-b8c8-8012-b9a4-23ff68a82a17 1/3
7/2/25, 5:13 PM Advanced DB Access Protocols
3️⃣
sql Copy Edit
GRANT REFERENCES (emp_id) ON employee TO user3;
✅ Explanation:
This allows user3 to:
Use the emp_id column as a foreign key in another table definition.
It ensures that values in a new table must match existing emp_id s in employee .
🔍 What user3 can do now:
sql Copy Edit
CREATE TABLE project ( project_id INT, emp_id INT, FOREIGN KEY (emp_id) REFERENCES
employee(emp_id) );
🚫 What user3 cannot do:
View, insert, update, or delete data from employee — only use emp_id for FK constraints.
4️⃣
sql Copy Edit
REVOKE INSERT ON employee FROM user1;
✅ Explanation:
This command removes the INSERT privilege previously granted to user1 .
After this command, user1 can no longer insert new rows into the employee table.
🔍 Now user1 can:
Still use SELECT to view data (that privilege is still intact).
🚫 But user1 can’t:
sql Copy Edit
https://chatgpt.com/c/6864b7be-b8c8-8012-b9a4-23ff68a82a17 2/3
7/2/25, 5:13 PM Advanced DB Access Protocols
-- This will now cause an error: INSERT INTO employee (emp_id, name, dept, salary) VALUES
(102, 'Neha', 'IT', 55000);
🧠 Summary Table:
Command Effect
GRANT SELECT, INSERT Allows reading and inserting data.
GRANT UPDATE (salary) Allows modifying only the salary column.
GRANT REFERENCES (emp_id) Allows using emp_id in foreign key definitions.
REVOKE INSERT Removes the ability to insert new records.
https://chatgpt.com/c/6864b7be-b8c8-8012-b9a4-23ff68a82a17 3/3