Examples SQL Privileges
Examples SQL Privileges
✅ 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 ).
SELECT * FROM employee; INSERT INTO employee (emp_id, name, dept, salary) VALUES (101,
'Amit', 'CS', 50000);
2️⃣
sql Copy Edit
✅ Explanation:
This command allows user2 to:
Modify (update) the value of the salary column only in the employee table.
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
✅ 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 .
CREATE TABLE project ( project_id INT, emp_id INT, FOREIGN KEY (emp_id) REFERENCES
employee(emp_id) );
4️⃣
sql Copy Edit
✅ 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.
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
https://chatgpt.com/c/6864b7be-b8c8-8012-b9a4-23ff68a82a17 3/3