Read-only user for a whole schema

Read-only user for a whole schema

Medium SQL DCL 20 views
Explanation Complexity

Problem Statement

Create user readonly_user, then give only SELECT access on all tables under schema sales_db. Keep it least-privilege (no insert/update/delete).

Input Format

SQL statements

Output Format

Privileges applied

Example

Schema sales_db exists
Read-only access

Constraints

Syntax varies by database

Input / Output Format

Input Format
SQL statements
Output Format
Privileges applied
Constraints
Syntax varies by database

Examples

Input:
Schema sales_db exists
Output:
Read-only access

Example Solution (Public)

SQL
CREATE USER readonly_user IDENTIFIED BY 'StrongPass123'; GRANT SELECT ON ALL TABLES IN SCHEMA sales_db TO readonly_user;

Official Solution Code

CREATE USER readonly_user IDENTIFIED BY 'StrongPass123'; GRANT SELECT ON ALL TABLES IN SCHEMA sales_db TO readonly_user;
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.