Before you beginReview the provider and consumer model
A direct share crosses two accounts and three access checks
Maple Market grants access to a secure view and adds the approved partner account. The partner imports that share, then decides which local users can query the imported database. Those checks handle different questions. The provider decides which account and data. The consumer decides which users and warehouse. The view decides which approved region the account sees.
For the lab, use two approved Snowflake accounts in the same region with provider sharing enabled and one existing warehouse per account. Admin and analyst sessions are separate. Keep production accounts and real customer data out of the exercise.
- Provider roleGrant the view and add account to Account invitation
- Account invitationCreate database from share to Consumer importer
- Consumer importerGrant imported privileges to Consumer analyst
- Provider role
- Owns the secure view and share.
- Account invitation
- Uses the approved consumer identifier.
- Consumer importer
- Mounts the inbound share and grants access.
- Consumer analyst
- Uses the local account role and warehouse.
Set up the two accounts and role boundaries
Run the identity query in both accounts first. Use the consumer organization and account names for ALTER SHARE. Record the provider locator for CREATE DATABASE FROM SHARE and the consumer locators for the view filter. They are different fields. Check CURRENT_REGION before testing the invite.
On the provider, the administrator grants CREATE DATABASE for the disposable source, CREATE SHARE to make the share and MANAGE SHARE TARGET to add or remove accounts on a share the role owns. A different grantor needs the relevant object privileges WITH GRANT OPTION and authority to resolve the share. We let one disposable lab role own the source objects and share. The partner’s administrator performs the import. A delegated importer could use CREATE DATABASE plus IMPORT SHARE. The analyst needs neither global privilege.
Create and test the protected fixture before inviting the consumer →
Read account and region details in each account
SELECT CURRENT_ORGANIZATION_NAME() AS ORG_NAME,
CURRENT_ACCOUNT_NAME() AS ACCOUNT_NAME,
CURRENT_ACCOUNT() AS ACCOUNT_LOCATOR,
CURRENT_REGION() AS REGION;Grant the provider role in the provider account
-- Provider account. Use existing approved identities and warehouse.
USE ROLE ACCOUNTADMIN;
CREATE ROLE M19_SHARE_ADMIN;
GRANT CREATE DATABASE, CREATE SHARE, MANAGE SHARE TARGET
ON ACCOUNT TO ROLE M19_SHARE_ADMIN;
GRANT USAGE ON WAREHOUSE <provider_lab_warehouse> TO ROLE M19_SHARE_ADMIN;
GRANT ROLE M19_SHARE_ADMIN TO USER <provider_operator>;Grant the analyst role in the consumer account
-- Consumer account only.
USE ROLE ACCOUNTADMIN;
CREATE ROLE M19_PARTNER_ANALYST;
GRANT ROLE M19_PARTNER_ANALYST TO USER <consumer_analyst>;
GRANT USAGE ON WAREHOUSE <consumer_lab_warehouse> TO ROLE M19_PARTNER_ANALYST;Create the provider share and add only the approved consumer
As M19_SHARE_ADMIN build the source and secure view first. CREATE SHARE makes an empty share that accepts secure views by default. Grant USAGE on the database and published schema and SELECT on the one view. SHOW GRANTS TO SHARE should list just those object grants. Approve the account match before running ALTER SHARE. ADD adds only the named account. Avoid replacing the whole target list when making a single change.
Create the share and confirm its object grants
-- Provider account as M19_SHARE_ADMIN.
CREATE SHARE MAPLE_M19_SALES_SHARE SECURE_OBJECTS_ONLY = TRUE;
GRANT USAGE ON DATABASE LS_M19_SHARE_LAB TO SHARE MAPLE_M19_SALES_SHARE;
GRANT USAGE ON SCHEMA LS_M19_SHARE_LAB.PARTNER TO SHARE MAPLE_M19_SALES_SHARE;
GRANT SELECT ON VIEW LS_M19_SHARE_LAB.PARTNER.SALES_DAILY TO SHARE MAPLE_M19_SALES_SHARE;
SHOW GRANTS TO SHARE MAPLE_M19_SALES_SHARE;Invite the India test account
-- Provider account as M19_SHARE_ADMIN.
ALTER SHARE MAPLE_M19_SALES_SHARE ADD ACCOUNTS = <consumer_org>.<consumer_account>;
SHOW GRANTS OF SHARE MAPLE_M19_SALES_SHARE;Mount the inbound share and test the analyst session
In the consumer account confirm the inbound share matches the approved provider. The database name on the left is local. The value after FROM SHARE identifies the provider share. The importer grants IMPORTED PRIVILEGES to the local analyst for the directly granted objects. SELECT on the underlying provider tables is outside that grant.
Run the analyst block in the assigned test session. The expected output is IN, 2026-01-06, 2, 150.00. If the inbound share is absent, check the region, provider target list and account identifier. If the import exists but the role cannot query, check local grants and warehouse usage. An empty successful query calls for checking the locator against the provider’s map.
Discover the share and create the imported database
-- Consumer account as ACCOUNTADMIN.
SHOW SHARES LIKE 'MAPLE_M19_SALES_SHARE';
CREATE DATABASE MAPLE_M19_IMPORTED FROM SHARE <verified_provider_locator>.MAPLE_M19_SALES_SHARE;
GRANT IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED TO ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Read the published India totals as the analyst
-- Consumer account in the assigned analyst's session.
USE ROLE M19_PARTNER_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE <consumer_lab_warehouse>;
SELECT CURRENT_ROLE(), CURRENT_ACCOUNT();
SELECT REGION, SALE_DATE, ORDER_COUNT, NET_SALES
FROM MAPLE_M19_IMPORTED.PARTNER.SALES_DAILY ORDER BY REGION, SALE_DATE;Verify a correction, a role denial and provider revocation
The correction updates one base row in place. After commit, rerun the same analyst query. The India total changes to 175 without recreating the import. Replacing or creating a new provider object is different. Explicitly grant the replacement to the share or verify preserved grants through the supported replacement procedure before releasing it.
To test local access, remove and restore only the analyst grant in the consumer account, with secondary roles off for the readback. To end the entire account’s live access, the provider removes the account from its targets and tests the read again. Revoking SELECT on the view from a share affects every target of that share, so use that only when retiring the object for all intended recipients. Keep the query IDs and allow for separately retained copies.
| Checkpoint | Provider IN | Provider EU | India consumer IN |
|---|---|---|---|
| First query | 2 orders / 150.00 | 1 order / 200.00 | 2 orders / 150.00 |
| Provider corrects order 701 from 100 to 125 | 2 orders / 175.00 | 1 order / 200.00 | 2 orders / 175.00 after the commit |
| Local analyst privilege revoked | Unchanged | Unchanged | Query denied |
| Local privilege restored | Unchanged | Unchanged | 2 orders / 175.00 |
| Provider removes the consumer account | Unchanged | Unchanged | Share access revoked |
Follow the full sequence including cleanup →
Correct the provider sale and verify the source
-- Provider account as M19_SHARE_ADMIN. Keep the same view and share.
UPDATE LS_M19_SHARE_LAB.CORE.SALES SET NET_AMOUNT = 125
WHERE SALE_ID = 701 AND NET_AMOUNT = 100;
SELECT REGION, COUNT(*) AS ORDER_COUNT, SUM(NET_AMOUNT) AS NET_SALES
FROM LS_M19_SHARE_LAB.CORE.SALES GROUP BY REGION ORDER BY REGION;Create a controlled local permission failure
-- Consumer account, as the role that created MAPLE_M19_IMPORTED.
USE ROLE ACCOUNTADMIN;
REVOKE IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED FROM ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Restore the intended role grant
-- Consumer account as ACCOUNTADMIN.
GRANT IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED TO ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Remove the consumer account when the pilot ends
-- Provider account as M19_SHARE_ADMIN.
ALTER SHARE MAPLE_M19_SALES_SHARE REMOVE ACCOUNTS = <consumer_org>.<consumer_account>;
SHOW GRANTS OF SHARE MAPLE_M19_SALES_SHARE;Segment imported objects with a shared database role
Use this alternative only with a separate scratch share. In the provider account a database role bundles read permissions over selected objects in its database. Grant that role to the share instead of granting the view directly. Database roles do not support future grants when shared. A secure view spanning several databases cannot use this role-based pattern. See the reference on sharing with REFERENCE_USAGE for that case.
In the consumer account grant the imported database role to the account analyst role. IMPORTED PRIVILEGES is for the directly granted objects and does not grant the provider’s shared database role. Validate access by switching to the analyst rather than querying as the importer. Before the capstone cleanup, remove the alternate target and drop the alternate import, share and database role if you ran this example.
Publish a scoped database role from the provider
USE ROLE M19_SHARE_ADMIN;
CREATE DATABASE ROLE LS_M19_SHARE_LAB.PARTNER_DAILY_READ;
GRANT USAGE ON DATABASE LS_M19_SHARE_LAB TO DATABASE ROLE LS_M19_SHARE_LAB.PARTNER_DAILY_READ;
GRANT USAGE ON SCHEMA LS_M19_SHARE_LAB.PARTNER TO DATABASE ROLE LS_M19_SHARE_LAB.PARTNER_DAILY_READ;
GRANT SELECT ON VIEW LS_M19_SHARE_LAB.PARTNER.SALES_DAILY
TO DATABASE ROLE LS_M19_SHARE_LAB.PARTNER_DAILY_READ;
CREATE SHARE MAPLE_M19_ROLE_OPTION;
GRANT USAGE ON DATABASE LS_M19_SHARE_LAB TO SHARE MAPLE_M19_ROLE_OPTION;
GRANT DATABASE ROLE LS_M19_SHARE_LAB.PARTNER_DAILY_READ TO SHARE MAPLE_M19_ROLE_OPTION;
ALTER SHARE MAPLE_M19_ROLE_OPTION ADD ACCOUNTS = <consumer_org>.<consumer_account>;Assign the imported role in the consumer
USE ROLE ACCOUNTADMIN;
CREATE DATABASE MAPLE_M19_ROLE_IMPORTED FROM SHARE <verified_provider_locator>.MAPLE_M19_ROLE_OPTION;
SHOW DATABASE ROLES IN DATABASE MAPLE_M19_ROLE_IMPORTED;
GRANT DATABASE ROLE MAPLE_M19_ROLE_IMPORTED.PARTNER_DAILY_READ TO ROLE M19_PARTNER_ANALYST;Interview practice
Explain the decision and the evidence you would use to test it.
Why does a consumer need a local role grant after import?
The invitation allows the account to mount the share. The local grant determines which roles can use the imported objects. The analyst also needs warehouse usage.
How do provider changes appear in the share?
I can update a row in the provider table and query the same view after commit. If I replace the view, I verify the object grant again because object identity can change.
How would you troubleshoot an analyst who gets no data?
I first tell apart a denied query and an empty result. For a denial I check the share target, object grants, local role and warehouse. For zero rows I verify the expected account locator and entitlement.
Words used in this lesson
- Direct share
- A named share to specified same-region Snowflake accounts.
- Imported privileges
- Consumer grant for objects directly granted to the share.
- Shared database role
- A provider-defined group of object privileges that the consumer assigns locally.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Snowflake direct shares: provider SQL, consumer imports and revocation
Direct share setup in both accounts
An account can be invited and still have no eligible local reader or no entitled data.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Direct share setup in both accounts
An account can be invited and still have no eligible local reader or no entitled data.
Provider role → Account invitation → Consumer importer → Consumer analyst
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
The datasets are fictional. Results are expected or simulated. Run live steps only in approved test accounts with the documented roles, regions, and feature access.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
What do you remove to stop just one consumer account from reading a share?
Compare your reasoning
Remove that account using ALTER SHARE ... REMOVE ACCOUNTS, verify the target list and retest the consumer read.
Connect this lesson to the learning path
Official sources and curriculum
Module 19 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab