Custom Roles & Database Roles
Account roles describe jobs and can be used by people. Database roles are access bundles that live inside one database and are granted to account roles and shares.
The problem
System roles are only the frame. IsmaFrost needs roles for its own jobs, and it needs a clean way to say "read access to SALES_DB" once, then reuse it for people and for a partner account.
The mental model
You create two kinds of role, and they answer different questions. An account role answers "what job does this person or service do?" (ANALYST, DATA_ENGINEER). A database role answers "what does read or write access to this one database look like?" (SALES_DB.READER). Account roles carry people. Database roles carry grants.
How it works: account roles
IsmaFrost's design is small on purpose (grant sheet, Access Model section). Youness creates DATA_ENGINEER for Thomas and ANALYST for Alice, Thomas and Amine, grants both to SYSADMIN, and keeps HR_ADMIN for Safia outside the tree. When Alice needs to test something Thomas owns, she doesn't get Thomas's role. Thomas grants the specific privilege to ANALYST.
USE ROLE useradmin; -- USERADMIN creates rolesCREATE ROLE analyst;CREATE ROLE data_engineer; USE ROLE securityadmin;-- IsmaFrost's convention: every grant goes through SECURITYADMIN, so the grant-- history sits with one role. (USERADMIN owns these roles and could grant them too.)GRANT ROLE analyst TO ROLE sysadmin;GRANT ROLE data_engineer TO ROLE sysadmin; GRANT ROLE analyst TO USER alice;GRANT ROLE analyst TO USER thomas;GRANT ROLE analyst TO USER amine;GRANT ROLE data_engineer TO USER thomas; -- warehouse and database USAGE: see the grant sheet SQL (Access Model section)
How it works: database roles
A database role is created inside one database and can hold privileges only on objects in that database. You grant it to account roles, to other database roles of the same database, or to a share. It can't be granted to a user, and it can't be activated in a session at all, neither as primary nor as secondary role. It reaches people only through an account role it is granted to. Snowflake grants it USAGE on its own database automatically, so you only add schema and object privileges. Figure 3.4 shows one bundle reaching two consumers in two accounts.
ISMAFROST ACCOUNT · PROVIDER
DATABASE SALES_DB
PRIVILEGEUSAGEon SALES_DB (automatic)
PRIVILEGEUSAGEon schema CORE
PRIVILEGESELECTALL tables in CORE
DATABASE ROLESALES_DB.
TO ROLE analyst
ROLEANALYSTaccount role
USERAliceuses ANALYST
SHAREPARTNER_
PRIVILEGEUSAGEon SALES_DB
A database role is never active in a session itself.
PARTNER · CONSUMER
DATABASEPARTNER_SALEScreated FROM SHAREread-only, no data copied
ARRIVES WITH THE SHAREPARTNER_SALES
GRANT DATABASE ROLE
ROLEREPORTINGthe partner’s own role
USE ROLE sysadmin;CREATE DATABASE ROLE sales_db. reader; GRANT USAGE ON SCHEMA sales_db. core TO DATABASE ROLE sales_ db. reader; GRANT SELECT ON ALL TABLES IN SCHEMA sales_db. core TO DATABASE ROLE sales_ db. reader; -- no FUTURE grant here: a database role granted to a share can't hold oneGRANT DATABASE ROLE sales_db. reader TO ROLE analyst; -- people (the share part comes below)
Expected result. Alice, through ANALYST, can read every table that existed in SALES_DB.CORE when the grant ran. The bundle brings USAGE on SALES_DB and CORE and SELECT on the tables; USAGE on BI_WH comes from ANALYST itself (grant sheet). Together that is everything one SELECT needs, as the Privileges & GRANT section shows. The partner account will see exactly the same slice through the share and nothing else in SALES_DB.
Database roles pay off three ways:
- The role lives inside the database, so it travels with clones and replicas.
- Per-database bundles stay out of the account-wide role list, which stays short.
- Granted to a share, a database role exposes one defined slice, so different consumers can get different slices.
A new analyst is then one role grant. A new table needs one more GRANT SELECT ON ALL TABLES against the bundle. The reason: a database role granted to a share can't hold future grants. Snowflake refuses that combination in either order ("Cannot share a database role with future grants to it").
Which one to use
| Account role | Database role | |
|---|---|---|
| Use it when | A person or service needs an identity to work with | You want a reusable access bundle for one database |
| Can be active in a session (primary or secondary) | Yes | No, only through an account role |
| Granted to | Users, other account roles | Account roles, database roles in the same database, shares |
| Privileges on | Anything in the account, including global privileges | Objects inside its own database only, never account-level privileges such as CREATE WAREHOUSE |
| Travels with clone or replication of the database | No (replicated separately as an account object) | Yes |
You already use database roles that Snowflake made: SNOWFLAKE.USAGE_VIEWER, SNOWFLAKE.GOVERNANCE_VIEWER and SNOWFLAKE.CORTEX_USER live inside SNOWFLAKE, a read-only database that Snowflake shares with every account (usage history, AI functions and more).
Where access control meets sharing
A share is an account-level object that holds grants and a list of consumer accounts. It contains no data. The provider grants privileges to the share. The consumer creates a read-only database from it (often called mounting the share: nothing is copied) and decides which of its own roles may use that database. Accounts are named organization.account, for example ismafrost_org.prod_acct. Part 5 covers costs, cross-region sharing and reader accounts. The grant mechanics belong here.
-- Provider account (IsmaFrost)CREATE SHARE partner_share; GRANT USAGE ON DATABASE sales_db TO SHARE partner_share; -- the share needs this too GRANT DATABASE ROLE sales_db. reader TO SHARE partner_ share; ALTER SHARE partner_share ADD ACCOUNTS = partner_ org. partner_ acct; -- Consumer accountCREATE DATABASE partner_sales FROM SHARE ismafrost_ org. prod_ acct. partner_ share; GRANT DATABASE ROLE partner_sales. reader TO ROLE reporting; -- hand out the slice role by role -- if the provider had granted objects to the share directly, without a database role,-- the consumer could only grant the whole imported database at once:-- GRANT IMPORTED PRIVILEGES ON DATABASE partner_sales TO ROLE reporting;
If objects were granted to the share directly, without a database role, the consumer can only grant IMPORTED PRIVILEGES on the whole database. Grants on single shared objects are refused.
A database role can never hold a privilege on an object in another database, and it can never be granted to a user. Any option that crosses either wall is wrong.
- Account role = an identity a session can use. Database role = a bundle granted to account roles and shares, never active in a session itself.
- Database roles hold only object privileges inside their own database.
GRANT DATABASE ROLE … TO SHAREships one defined slice of a database to another account. The share also needs USAGE on the database, and a shared database role can't carry FUTURE grants.- Objects shared directly: the consumer grants IMPORTED PRIVILEGES on the whole database. A shared database role: the consumer grants that role, slice by slice.

