Bird
Raised Fist0
Snowflakecloud~20 mins

Creating custom roles in Snowflake - Practice Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Snowflake Role Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Role Hierarchy in Snowflake

In Snowflake, when you create a custom role and grant it to another role, what is the effect on the privileges of the parent role?

AThe parent role can use privileges of the custom role only if the custom role is granted to it explicitly.
BThe custom role inherits all privileges of the parent role automatically.
CThe parent role inherits all privileges of the custom role automatically.
DPrivileges are not shared between roles regardless of grants.
Attempts:
2 left
💡 Hint

Think about how role inheritance works in Snowflake.

❓ Configuration
intermediate
2:00remaining
Creating a Custom Role with Specific Privileges

Which Snowflake SQL command correctly creates a custom role named data_analyst and grants it the privilege to select from the sales_data schema?

ACREATE ROLE data_analyst; GRANT SELECT ON DATABASE sales_data TO ROLE data_analyst;
BCREATE ROLE data_analyst; GRANT SELECT ON SCHEMA sales_data TO ROLE data_analyst;
CCREATE ROLE data_analyst; GRANT USAGE ON SCHEMA sales_data TO ROLE data_analyst;
DCREATE ROLE data_analyst; GRANT SELECT ON TABLE sales_data TO ROLE data_analyst;
Attempts:
2 left
💡 Hint

Remember that to select data, the role needs SELECT privilege on the schema or tables.

❓ Architecture
advanced
3:00remaining
Designing Role Hierarchy for Separation of Duties

You want to design a Snowflake role hierarchy to separate duties between data engineers and data analysts. Which design best enforces that data engineers can manage tables but cannot query data, while data analysts can query data but cannot manage tables?

ACreate a <code>data_engineer</code> role with CREATE and MODIFY privileges on tables, and a separate <code>data_analyst</code> role with SELECT privileges only; do not grant either role to the other.
BCreate a <code>data_analyst</code> role with all privileges and grant it to <code>data_engineer</code> role.
CCreate a single role with both CREATE and SELECT privileges and assign it to both engineers and analysts.
DCreate a <code>data_engineer</code> role with SELECT privileges and grant it to <code>data_analyst</code> role.
Attempts:
2 left
💡 Hint

Think about how granting roles affects privilege inheritance and separation.

❓ security
advanced
2:30remaining
Preventing Privilege Escalation with Custom Roles

Which practice helps prevent privilege escalation when creating custom roles in Snowflake?

AUse the PUBLIC role to grant all privileges to custom roles.
BGrant all privileges to custom roles to avoid permission errors during operations.
CAssign the ACCOUNTADMIN role to all users and then create custom roles for auditing.
DGrant only the minimum required privileges to each custom role and avoid granting powerful roles like ACCOUNTADMIN to users directly.
Attempts:
2 left
💡 Hint

Think about the principle of least privilege.

❓ service_behavior
expert
3:00remaining
Effect of Revoking a Role in a Role Hierarchy

Consider the following Snowflake role hierarchy: role_A is granted to role_B, and role_B is granted to role_C. If role_A is revoked from role_B, what is the effect on role_C?

A<code>role_C</code> loses all privileges inherited from <code>role_A</code> because the grant chain is broken.
B<code>role_C</code> retains privileges from <code>role_A</code> because it was granted directly.
C<code>role_C</code> gains additional privileges from <code>role_A</code> automatically.
DRevoking <code>role_A</code> from <code>role_B</code> has no effect on <code>role_C</code>.
Attempts:
2 left
💡 Hint

Consider how privilege inheritance works through role grants.

Practice

(1/5)
1. What is the main purpose of creating a custom role in Snowflake?
easy
A. To create a new user account
B. To store data in a new database
C. To run SQL queries faster
D. To control and manage user access permissions

Solution

  1. Step 1: Understand role purpose

    Custom roles in Snowflake are designed to manage what users can do by controlling permissions.
  2. Step 2: Identify correct function

    Creating a role is not about storing data, creating users, or speeding queries, but about access control.
  3. Final Answer:

    To control and manage user access permissions -> Option D
  4. Quick Check:

    Role purpose = Access control [OK]
Hint: Roles control permissions, not data or users [OK]
Common Mistakes:
  • Confusing roles with users
  • Thinking roles store data
  • Assuming roles speed up queries
2. Which of the following is the correct syntax to create a new role named data_analyst in Snowflake?
easy
A. CREATE ROLE data_analyst;
B. NEW ROLE data_analyst;
C. MAKE ROLE data_analyst;
D. ADD ROLE data_analyst;

Solution

  1. Step 1: Recall Snowflake role creation syntax

    The correct command to create a role is CREATE ROLE role_name;.
  2. Step 2: Match syntax with options

    Only CREATE ROLE data_analyst; uses the correct CREATE ROLE syntax.
  3. Final Answer:

    CREATE ROLE data_analyst; -> Option A
  4. Quick Check:

    CREATE ROLE = correct syntax [OK]
Hint: Use CREATE ROLE to make new roles [OK]
Common Mistakes:
  • Using NEW ROLE instead of CREATE ROLE
  • Using MAKE or ADD which are invalid
  • Missing semicolon at the end
3. Given the commands:
CREATE ROLE analyst;
GRANT USAGE ON DATABASE sales_db TO ROLE analyst;
GRANT ROLE analyst TO USER alice;

What permission does user alice have on sales_db?
medium
A. No permissions on sales_db
B. Only USAGE permission on sales_db
C. ALL permissions on sales_db
D. SELECT permission on sales_db

Solution

  1. Step 1: Analyze role creation and grants

    The role analyst is created and given USAGE permission on sales_db.
  2. Step 2: Check role assignment to user

    User alice is granted the analyst role, so she inherits its permissions.
  3. Final Answer:

    Only USAGE permission on sales_db -> Option B
  4. Quick Check:

    Role grants USAGE, user inherits USAGE [OK]
Hint: User gets permissions of assigned roles [OK]
Common Mistakes:
  • Assuming no permissions without direct grant
  • Confusing USAGE with SELECT permission
  • Ignoring role inheritance
4. You run this command:
CREATE ROLE analyst

but get an error. What is the likely cause?
medium
A. You must create a user before creating a role
B. Role name analyst is reserved and cannot be used
C. Missing semicolon at the end of the command
D. CREATE ROLE command is not supported in Snowflake

Solution

  1. Step 1: Check command syntax

    Snowflake commands require a semicolon at the end to execute properly.
  2. Step 2: Evaluate other options

    Role names like analyst are allowed, users are independent of roles, and CREATE ROLE is supported.
  3. Final Answer:

    Missing semicolon at the end of the command -> Option C
  4. Quick Check:

    Semicolon ends command [OK]
Hint: Always end SQL commands with a semicolon [OK]
Common Mistakes:
  • Forgetting semicolon causes syntax error
  • Thinking role names are restricted
  • Believing users must exist first
5. You want to create a custom role report_viewer that can only read data from the reports schema in the analytics database. Which sequence of commands correctly achieves this?
hard
A. CREATE ROLE report_viewer; GRANT USAGE ON DATABASE analytics TO ROLE report_viewer; GRANT USAGE ON SCHEMA analytics.reports TO ROLE report_viewer; GRANT SELECT ON ALL TABLES IN SCHEMA analytics.reports TO ROLE report_viewer;
B. CREATE ROLE report_viewer; GRANT SELECT ON DATABASE analytics TO ROLE report_viewer;
C. CREATE ROLE report_viewer; GRANT ALL ON SCHEMA analytics.reports TO ROLE report_viewer;
D. CREATE ROLE report_viewer; GRANT USAGE ON DATABASE analytics TO ROLE report_viewer; GRANT SELECT ON SCHEMA analytics.reports TO ROLE report_viewer;

Solution

  1. Step 1: Create the role

    Use CREATE ROLE report_viewer; to make the role.
  2. Step 2: Grant USAGE on database and schema

    Granting USAGE on the database and schema allows access to objects inside.
  3. Step 3: Grant SELECT on all tables in the schema

    Grant SELECT on all tables to allow read access to data.
  4. Step 4: Evaluate options

    CREATE ROLE report_viewer; GRANT USAGE ON DATABASE analytics TO ROLE report_viewer; GRANT USAGE ON SCHEMA analytics.reports TO ROLE report_viewer; GRANT SELECT ON ALL TABLES IN SCHEMA analytics.reports TO ROLE report_viewer; correctly grants USAGE and SELECT at proper levels. CREATE ROLE report_viewer; GRANT SELECT ON DATABASE analytics TO ROLE report_viewer; misses schema and USAGE grants. CREATE ROLE report_viewer; GRANT ALL ON SCHEMA analytics.reports TO ROLE report_viewer; grants ALL which is too broad. CREATE ROLE report_viewer; GRANT USAGE ON DATABASE analytics TO ROLE report_viewer; GRANT SELECT ON SCHEMA analytics.reports TO ROLE report_viewer; grants SELECT on schema which is invalid; SELECT must be on tables.
  5. Final Answer:

    CREATE ROLE report_viewer; GRANT USAGE ON DATABASE analytics TO ROLE report_viewer; GRANT USAGE ON SCHEMA analytics.reports TO ROLE report_viewer; GRANT SELECT ON ALL TABLES IN SCHEMA analytics.reports TO ROLE report_viewer; -> Option A
  6. Quick Check:

    Grant USAGE + SELECT on tables = read access [OK]
Hint: Grant USAGE on DB/schema, SELECT on tables for read-only role [OK]
Common Mistakes:
  • Granting SELECT on schema instead of tables
  • Missing USAGE grants on database or schema
  • Granting ALL permissions instead of SELECT only
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard