w3resource

SQL - Practical Security and Access Control Exercises


This resource offers a total of 100 SQL Security and Access Control problems for practice. It includes 20 main exercises, each accompanied by solutions, detailed explanations, and four related problems.


1. Granting SELECT Permission on a Table

Write a SQL query to grant SELECT permission on a table to a user.

Click me to see the solution

2. Revoking INSERT Permission on a Table

Write a SQL query to revoke INSERT permission on a table from a user.

Click me to see the solution

3. Granting EXECUTE Permission on a Stored Procedure

Write a SQL query to grant EXECUTE permission on a stored procedure to a user.

Click me to see the solution

4. Implementing Row-Level Security (RLS)

Write a SQL query to implement row-level security on a table.

Click me to see the solution

5. Implementing Column-Level Security (CLS)

Write a SQL query to implement column-level security using views.

Click me to see the solution

6. Creating a Database Role and Assigning Permissions

Write a SQL query to create a database role and assign permissions to it.

Click me to see the solution

7. Enabling Data Masking for Sensitive Columns

Write a SQL query to enable dynamic data masking on a sensitive column.

Click me to see the solution

8. Auditing user Access to Sensitive Data

Write a SQL query to audit user access to sensitive data using triggers.

Click me to see the solution

9. Restricting Schema Modifications with DDL Triggers

Write a SQL query to restrict schema modifications using DDL triggers.

Click me to see the solution

10. Encrypting a Database Column

Write a SQL query to encrypt a sensitive column using Transparent Data Encryption (TDE).

Click me to see the solution

11. Creating a Login and Mapping It to a user

Write a SQL query to create a login and map it to a database user.

Click me to see the solution

12. Denying DELETE Permission on a Table

Write a SQL query to deny DELETE permission on a table to a user.

Click me to see the solution

13. Using Certificates for Database Authentication

Write a SQL query to create and use a certificate for database authentication.

Click me to see the solution

14. Enforcing Password Policies for SQL Logins

Write a SQL query to enforce password policies for SQL logins.

Click me to see the solution

15. Granting Ownership of a Schema to a User

Write a SQL query to grant ownership of a schema to a user.

Click me to see the solution

16. Implementing Role-Based Access Control (RBAC)

Write a SQL query to implement role-based access control (RBAC) for a database.

Click me to see the solution

17. Auditing Failed Login Attempts

Write a SQL query to audit failed login attempts using SQL Server Audit.

Click me to see the solution

18. Enabling Always Encrypted for Sensitive Data

Write a SQL query to enable always Encrypted for a sensitive column.

Click me to see the solution

19. Implementing Multi-Factor Authentication (MFA)

Write a SQL query to configure multi-factor authentication (MFA) for database access.

Click me to see the solution

20. Revoking All Permissions from a User

Write a SQL query to revoke all permissions from a user.

Click me to see the solution

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Follow us on Facebook and Twitter for latest update.