Setting Up Role-Based Access Control in Snowflake

Setting Up Role-Based Access Control in Snowflake: A Template for Growing Teams

Celestinfo Software Solutions Pvt. Ltd. • Mar 13, 2025

Last updated: October 2026

Quick answer: Create functional roles (DATA_ENGINEER, DATA_ANALYST, etc.) under SYSADMIN, grant specific privileges per role, use future grants so new tables auto-inherit permissions, create service users with TYPE = SERVICE and key-pair authentication, and never use ACCOUNTADMIN for daily work. This article includes a complete SQL script you can run to set up a multi-team RBAC environment from scratch.

Snowflake's Built-In Role Hierarchy


Every Snowflake account has a set of system-defined roles. Understanding the hierarchy is the first step to building your own:



Why You Should Never Use ACCOUNTADMIN Daily


Three concrete reasons. First, blast radius: every accidental DROP DATABASE hits every database in the account. Second, audit trail: when 8 people share ACCOUNTADMIN, your audit logs show the same role for every action, so you can't tell who did what. Third, compliance: SOC 2 and HIPAA auditors specifically look for least-privilege enforcement. If your data engineers are running queries as ACCOUNTADMIN, that's a finding.


Designing Your Role Hierarchy


Here's a role template that works for most data teams of 5 to 50 people. You'll create functional roles for each team function and grant them to SYSADMIN so the hierarchy stays clean:


RolePurposeTypical Privileges
DATA_ENGINEERBuild and maintain pipelinesCREATE TABLE, INSERT, UPDATE, DELETE, CREATE TASK, CREATE STREAM on assigned schemas, plus EXECUTE TASK on the account
DATA_ANALYSTQuery and report on dataSELECT on analytics schemas, USAGE on BI warehouse
DATA_SCIENTISTExplore data, build modelsSELECT on analytics + raw schemas, USAGE on ML warehouse, CREATE STAGE
BI_DEVELOPERBuild dashboards and semantic layersSELECT on analytics schemas, USAGE on BI warehouse
APP_SERVICE_ACCOUNTApplication-level read accessSELECT on specific views only, USAGE on app warehouse with tight resource monitor

One default works against this design. New users have DEFAULT_SECONDARY_ROLES set to ALL, so every role granted to a user is active as a secondary role in each session. A user who holds both DATA_ENGINEER and DATA_ANALYST therefore acts with the privileges of both, except for CREATE statements, which use the primary role. Where each session should be limited to one functional role, set DEFAULT_SECONDARY_ROLES = () on those users or run USE SECONDARY ROLES NONE.


Does this need to survive an audit? Role hierarchies, masking policies and row access rules are quick to draw and hard to keep correct once several teams are changing them. We implement the model in your account and leave behind the tests that prove it still holds next quarter.

Book a governance review Data engineering services

Complete SQL Setup Script


Run this as USERADMIN to create roles and users, SYSADMIN to create databases and warehouses, and SECURITYADMIN for the grants. The script sets up the full role template from the table above:


SQL - RBAC Setup Script
-- ============================================
-- Step 1: Create functional roles (as USERADMIN)
-- ============================================
USE ROLE USERADMIN;
CREATE ROLE IF NOT EXISTS DATA_ENGINEER;
CREATE ROLE IF NOT EXISTS DATA_ANALYST;
CREATE ROLE IF NOT EXISTS DATA_SCIENTIST;
CREATE ROLE IF NOT EXISTS BI_DEVELOPER;
CREATE ROLE IF NOT EXISTS APP_SERVICE_ACCOUNT;
-- Grant all custom roles to SYSADMIN (maintains hierarchy)
GRANT ROLE DATA_ENGINEER TO ROLE SYSADMIN;
GRANT ROLE DATA_ANALYST TO ROLE SYSADMIN;
GRANT ROLE DATA_SCIENTIST TO ROLE SYSADMIN;
GRANT ROLE BI_DEVELOPER TO ROLE SYSADMIN;
GRANT ROLE APP_SERVICE_ACCOUNT TO ROLE SYSADMIN;
-- ============================================
-- Step 2: Create warehouses (as SYSADMIN)
-- Without GENERATION, new standard warehouses are Gen2 where available,
-- and query acceleration is on by default.
-- ============================================
USE ROLE SYSADMIN;
CREATE WAREHOUSE IF NOT EXISTS ETL_WH
  WAREHOUSE_SIZE = 'MEDIUM'
  AUTO_SUSPEND = 60
  AUTO_RESUME = TRUE;
CREATE WAREHOUSE IF NOT EXISTS BI_WH
  WAREHOUSE_SIZE = 'SMALL'
  AUTO_SUSPEND = 120
  AUTO_RESUME = TRUE;
CREATE WAREHOUSE IF NOT EXISTS ML_WH
  WAREHOUSE_SIZE = 'LARGE'
  AUTO_SUSPEND = 60
  AUTO_RESUME = TRUE;
CREATE WAREHOUSE IF NOT EXISTS APP_WH
  WAREHOUSE_SIZE = 'XSMALL'
  AUTO_SUSPEND = 60
  AUTO_RESUME = TRUE
  ENABLE_QUERY_ACCELERATION = FALSE;  -- keep the app warehouse's cost predictable
-- ============================================
-- Step 3: Grant warehouse access
-- ============================================
USE ROLE SECURITYADMIN;
GRANT USAGE ON WAREHOUSE ETL_WH TO ROLE DATA_ENGINEER;
GRANT USAGE ON WAREHOUSE BI_WH TO ROLE DATA_ANALYST;
GRANT USAGE ON WAREHOUSE BI_WH TO ROLE BI_DEVELOPER;
GRANT USAGE ON WAREHOUSE ML_WH TO ROLE DATA_SCIENTIST;
GRANT USAGE ON WAREHOUSE APP_WH TO ROLE APP_SERVICE_ACCOUNT;
-- ============================================
-- Step 4: Create databases and schemas (as SYSADMIN)
-- ============================================
USE ROLE SYSADMIN;
CREATE DATABASE IF NOT EXISTS RAW_DB;
CREATE DATABASE IF NOT EXISTS ANALYTICS_DB;
CREATE SCHEMA IF NOT EXISTS RAW_DB.INGESTION;
CREATE SCHEMA IF NOT EXISTS RAW_DB.STAGING;
CREATE SCHEMA IF NOT EXISTS ANALYTICS_DB.MARTS;
CREATE SCHEMA IF NOT EXISTS ANALYTICS_DB.REPORTS;
-- ============================================
-- Step 5: Database, schema and object privileges
-- ============================================
USE ROLE SECURITYADMIN;
-- DATA_ENGINEER: build in RAW_DB, read and create in ANALYTICS_DB
GRANT USAGE ON DATABASE RAW_DB TO ROLE DATA_ENGINEER;
GRANT USAGE ON ALL SCHEMAS IN DATABASE RAW_DB TO ROLE DATA_ENGINEER;
GRANT CREATE TABLE, CREATE VIEW, CREATE STREAM, CREATE TASK
  ON SCHEMA RAW_DB.INGESTION TO ROLE DATA_ENGINEER;
GRANT CREATE TABLE, CREATE VIEW
  ON SCHEMA RAW_DB.STAGING TO ROLE DATA_ENGINEER;
GRANT USAGE ON DATABASE ANALYTICS_DB TO ROLE DATA_ENGINEER;
GRANT USAGE ON ALL SCHEMAS IN DATABASE ANALYTICS_DB TO ROLE DATA_ENGINEER;
GRANT CREATE TABLE, CREATE VIEW
  ON SCHEMA ANALYTICS_DB.MARTS TO ROLE DATA_ENGINEER;
-- DATA_ANALYST and BI_DEVELOPER: read-only on analytics
GRANT USAGE ON DATABASE ANALYTICS_DB TO ROLE DATA_ANALYST;
GRANT USAGE ON ALL SCHEMAS IN DATABASE ANALYTICS_DB TO ROLE DATA_ANALYST;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE DATA_ANALYST;
GRANT SELECT ON ALL VIEWS IN SCHEMA ANALYTICS_DB.REPORTS TO ROLE DATA_ANALYST;
GRANT USAGE ON DATABASE ANALYTICS_DB TO ROLE BI_DEVELOPER;
GRANT USAGE ON ALL SCHEMAS IN DATABASE ANALYTICS_DB TO ROLE BI_DEVELOPER;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE BI_DEVELOPER;
GRANT SELECT ON ALL VIEWS IN SCHEMA ANALYTICS_DB.REPORTS TO ROLE BI_DEVELOPER;
-- DATA_SCIENTIST: read on staged raw data and on analytics
GRANT USAGE ON DATABASE RAW_DB TO ROLE DATA_SCIENTIST;
GRANT USAGE ON ALL SCHEMAS IN DATABASE RAW_DB TO ROLE DATA_SCIENTIST;
GRANT SELECT ON ALL TABLES IN SCHEMA RAW_DB.STAGING TO ROLE DATA_SCIENTIST;
GRANT USAGE ON DATABASE ANALYTICS_DB TO ROLE DATA_SCIENTIST;
GRANT USAGE ON ALL SCHEMAS IN DATABASE ANALYTICS_DB TO ROLE DATA_SCIENTIST;
GRANT SELECT ON ALL TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE DATA_SCIENTIST;
-- APP_SERVICE_ACCOUNT: specific views only (replace with your application's views)
GRANT USAGE ON DATABASE ANALYTICS_DB TO ROLE APP_SERVICE_ACCOUNT;
GRANT USAGE ON SCHEMA ANALYTICS_DB.REPORTS TO ROLE APP_SERVICE_ACCOUNT;
GRANT SELECT ON VIEW ANALYTICS_DB.REPORTS.ORDER_STATUS_V TO ROLE APP_SERVICE_ACCOUNT;
-- ============================================
-- Step 6: Future grants (auto-apply to new objects)
-- ============================================
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE DATA_ANALYST;
GRANT SELECT ON FUTURE VIEWS IN SCHEMA ANALYTICS_DB.REPORTS TO ROLE DATA_ANALYST;
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE BI_DEVELOPER;
GRANT SELECT ON FUTURE VIEWS IN SCHEMA ANALYTICS_DB.REPORTS TO ROLE BI_DEVELOPER;
GRANT SELECT ON FUTURE TABLES IN SCHEMA RAW_DB.STAGING TO ROLE DATA_SCIENTIST;
GRANT SELECT ON FUTURE TABLES IN SCHEMA ANALYTICS_DB.MARTS TO ROLE DATA_SCIENTIST;
-- ============================================
-- Step 7: Account-level privilege to run and resume tasks
-- ============================================
USE ROLE ACCOUNTADMIN;
GRANT EXECUTE TASK ON ACCOUNT TO ROLE DATA_ENGINEER;
-- ============================================
-- Step 8: Service user and role assignments
-- ============================================
USE ROLE USERADMIN;
CREATE USER IF NOT EXISTS app_service_user
  TYPE = SERVICE
  DEFAULT_ROLE = APP_SERVICE_ACCOUNT
  DEFAULT_WAREHOUSE = APP_WH
  RSA_PUBLIC_KEY = '<public key>';
USE ROLE SECURITYADMIN;
GRANT ROLE APP_SERVICE_ACCOUNT TO USER app_service_user;
GRANT ROLE DATA_ENGINEER TO USER jane_engineer;
GRANT ROLE DATA_ANALYST TO USER bob_analyst;
GRANT ROLE DATA_SCIENTIST TO USER alice_ml;

Future Grants: Don't Skip This


Without future grants, every new table you create requires a manual GRANT before analysts can see it. In practice, this means someone creates a table, an analyst files a ticket, and 3 days later they can finally query it. Future grants fix this:


SQL
-- Every new table in MARTS is automatically SELECTable by analysts
GRANT SELECT ON FUTURE TABLES IN SCHEMA analytics_db.marts
  TO ROLE DATA_ANALYST;

Future grants apply to objects created after the grant is set. They don't retroactively apply to existing objects. So run both GRANT SELECT ON ALL TABLES (for existing) and GRANT SELECT ON FUTURE TABLES (for new ones).


Database roles are another way to build this access layer. A database role is scoped to a single database and is granted to account roles, and it cannot be activated directly in a session. A common pattern is to create read and write database roles inside each database and grant them to the functional roles above, which keeps the grants for a database together with that database.


Managed Access Schemas


In a regular schema, whoever creates a table can grant access to it. This leads to sprawl: an engineer creates a staging table and grants SELECT to a random user, bypassing your role hierarchy entirely.


Managed access schemas fix this. In a managed access schema, only the schema owner, or a role with the MANAGE GRANTS privilege such as SECURITYADMIN, can grant privileges on the objects inside it:

SQL
CREATE SCHEMA analytics_db.secure_marts WITH MANAGED ACCESS;

-- Now only the schema owner (the role that ran this CREATE), or a role
-- with MANAGE GRANTS, can grant SELECT on tables in secure_marts.
-- Table creators cannot grant access themselves.

Service Account Best Practices


Service accounts (for BI tools, applications, ETL orchestrators) need special attention:



The ACCOUNTADMIN Ownership Gotcha


This trips up nearly every team at least once. If you're logged in as ACCOUNTADMIN and run CREATE DATABASE analytics_db, that database is owned by ACCOUNTADMIN. SYSADMIN can't see it, can't manage it, and can't grant access to it, even though SYSADMIN is meant to own all databases.


The fix: always switch to SYSADMIN before creating databases and schemas. If you've already created objects as ACCOUNTADMIN, transfer ownership:

SQL
GRANT OWNERSHIP ON DATABASE analytics_db TO ROLE SYSADMIN
  COPY CURRENT GRANTS;

Key Takeaways



Frequently Asked Questions

Q: Why shouldn't I use ACCOUNTADMIN for daily work in Snowflake?

ACCOUNTADMIN has unrestricted access to every object in the account. Using it daily violates least-privilege principles, increases the blast radius of mistakes, and makes audit trails meaningless since every action appears under the same all-powerful role.

Q: What are future grants in Snowflake?

Future grants automatically apply privileges to objects that don't exist yet. For example, GRANT SELECT ON FUTURE TABLES IN SCHEMA analytics TO ROLE DATA_ANALYST ensures every new table created in that schema automatically gets SELECT access for the DATA_ANALYST role.

Q: What is a managed access schema in Snowflake?

In a managed access schema, only the schema owner, or a role with the MANAGE GRANTS privilege, can grant privileges on objects within it. Individual table creators cannot grant access to their own tables, which centralises access control and prevents ad-hoc permission sprawl.

Q: What happens when I create a database as ACCOUNTADMIN?

The database is owned by ACCOUNTADMIN, not SYSADMIN. This means SYSADMIN cannot manage it or grant access to it. Best practice is to always create databases as SYSADMIN, or immediately transfer ownership after creation.

Share this article:
Ameer Shaik, Data Governance Specialist

Ameer Shaik is a Data Governance Specialist at CelestInfo focused on RBAC, compliance frameworks, data security, and access control across cloud data platforms.

Related Articles

Burning Questions
About CelestInfo

Simple answers to make things clear.

Our AI insights are continuously trained on large datasets and validated by experts to ensure high accuracy.

Absolutely. CelestInfo supports integration with a wide range of industry-standard software and tools.

We implement enterprise-grade encryption, access controls, and regular audits to ensure your data is safe.

Insights are updated in real-time as new data becomes available.

We offer 24/7 support via chat, email, and dedicated account managers.

Still have questions?

Get Assistance

Ready? Let's Talk!

Get expert insights and answers tailored to your business requirements and transformation.

Get Assistance