DCLs
DCLs
1. GRANT Queries
(Gives privileges to users)
1. GRANT SELECT ON Students TO user1; – Allows user1 to read data from the
"Students" table.
2. GRANT INSERT, UPDATE ON Employees TO user2; – Grants user2 permission to
insert and update data in "Employees".
3. GRANT ALL PRIVILEGES ON Orders TO user3; – Gives user3 full access to the
"Orders" table.
4. GRANT DELETE ON Products TO user4; – Allows user4 to delete records from the
"Products" table.
5. GRANT SELECT ON Customers TO PUBLIC; – Grants read access to all users on the
"Customers" table.
6. GRANT EXECUTE ON PROCEDURE GetEmployeeDetails TO user5; – Allows user5
to execute a stored procedure.
7. GRANT CREATE TABLE TO developer; – Grants the ability to create tables to
developer.
8. GRANT ALTER ON Employees TO manager; – Allows manager to modify the
structure of the "Employees" table.
9. GRANT UPDATE (Salary) ON Employees TO hr_team; – Allows hr_team to update
only the "Salary" column.
10. GRANT SELECT ON ALL TABLES IN SCHEMA sales TO analyst; – Grants read
access to all tables in the "sales" schema.
2. REVOKE Queries
(Removes privileges from users)
1. REVOKE SELECT ON Students FROM user1; – Removes read access from user1.
2. REVOKE INSERT, UPDATE ON Employees FROM user2; – Prevents user2 from
modifying "Employees".
3. REVOKE ALL PRIVILEGES ON Orders FROM user3; – Revokes all rights from
user3.
4. REVOKE DELETE ON Products FROM user4; – Prevents user4 from deleting records
in "Products".
5. REVOKE SELECT ON Customers FROM PUBLIC; – Removes read access for all users.
6. REVOKE EXECUTE ON PROCEDURE GetEmployeeDetails FROM user5; – Prevents
user5 from running the stored procedure.
7. REVOKE CREATE TABLE FROM developer; – Removes permission for developer to
create tables.
8. REVOKE ALTER ON Employees FROM manager; – Prevents manager from modifying
table structure.
9. REVOKE UPDATE (Salary) ON Employees FROM hr_team; – Removes the ability to
update salaries from hr_team.
10. REVOKE SELECT ON ALL TABLES IN SCHEMA sales FROM analyst; – Removes
read access from analyst.
Summary