0% found this document useful (0 votes)
1 views2 pages

DCLs

The document outlines SQL Data Control Language (DCL) queries for granting and revoking privileges to users. It provides examples of GRANT queries that assign various permissions on tables and procedures, as well as REVOKE queries that remove those permissions. The key takeaway is that GRANT is used to provide access rights, while REVOKE is used to remove them.

Uploaded by

muhib.lambay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

DCLs

The document outlines SQL Data Control Language (DCL) queries for granting and revoking privileges to users. It provides examples of GRANT queries that assign various permissions on tables and procedures, as well as REVOKE queries that remove those permissions. The key takeaway is that GRANT is used to provide access rights, while REVOKE is used to remove them.

Uploaded by

muhib.lambay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL DCL queries for GRANT and REVOKE in:

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

 GRANT is used to provide access rights.


 REVOKE is used to remove access rights.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy