📖 Scenario: You are a Snowflake administrator for a company. You need to create a custom role to manage access for the marketing team. This role will have specific privileges to query certain databases but not full admin rights.
🎯 Goal: Build a Snowflake role named MARKETING_ROLE with select privileges on the MARKETING_DB database schema.
📋 What You'll Learn
Create a role named MARKETING_ROLE
Grant usage on the MARKETING_DB database to MARKETING_ROLE
Grant usage privilege on the MARKETING_SCHEMA schema inside MARKETING_DB to MARKETING_ROLE
Grant select privilege on all tables inside MARKETING_SCHEMA to MARKETING_ROLE
💡 Why This Matters
🌍 Real World
Companies use custom roles in Snowflake to control who can access what data securely and efficiently.
💼 Career
Cloud administrators and data engineers often create and manage roles to enforce data governance and security policies.
Progress0 / 4 steps
1
Create the custom role
Write a SQL statement to create a role named MARKETING_ROLE.
Snowflake
Hint
Use the CREATE ROLE command followed by the role name.
2
Grant usage on the database
Write a SQL statement to grant usage on the database MARKETING_DB to the role MARKETING_ROLE.
Snowflake
Hint
Use GRANT USAGE ON DATABASE followed by the database name and TO ROLE with the role name.
3
Grant usage on the schema and select on tables
Write SQL statements to grant usage privilege on the schema MARKETING_SCHEMA inside MARKETING_DB and select privilege on all tables in that schema to the role MARKETING_ROLE.
Snowflake
Hint
First grant usage on the schema, then grant select on all tables in that schema.
4
Complete role setup with future grants
Write a SQL statement to grant select privilege on all future tables in MARKETING_SCHEMA inside MARKETING_DB to the role MARKETING_ROLE.
Snowflake
Hint
Use GRANT SELECT ON FUTURE TABLES IN SCHEMA to cover tables created later.
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
Step 1: Understand role purpose
Custom roles in Snowflake are designed to manage what users can do by controlling permissions.
Step 2: Identify correct function
Creating a role is not about storing data, creating users, or speeding queries, but about access control.
Final Answer:
To control and manage user access permissions -> Option D
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
Step 1: Recall Snowflake role creation syntax
The correct command to create a role is CREATE ROLE role_name;.
Step 2: Match syntax with options
Only CREATE ROLE data_analyst; uses the correct CREATE ROLE syntax.
Final Answer:
CREATE ROLE data_analyst; -> Option A
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
Step 1: Analyze role creation and grants
The role analyst is created and given USAGE permission on sales_db.
Step 2: Check role assignment to user
User alice is granted the analyst role, so she inherits its permissions.
Final Answer:
Only USAGE permission on sales_db -> Option B
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
Step 1: Check command syntax
Snowflake commands require a semicolon at the end to execute properly.
Step 2: Evaluate other options
Role names like analyst are allowed, users are independent of roles, and CREATE ROLE is supported.
Final Answer:
Missing semicolon at the end of the command -> Option C
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
Step 1: Create the role
Use CREATE ROLE report_viewer; to make the role.
Step 2: Grant USAGE on database and schema
Granting USAGE on the database and schema allows access to objects inside.
Step 3: Grant SELECT on all tables in the schema
Grant SELECT on all tables to allow read access to data.
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.
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
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 unknownstrongwhile earning +1 Grip toward your certificate.