Course contents

SnowPro Core COF-C03 Study GuidePart 5: Data protection and sharingSecure Data Sharing Fundamentals

Secure Data Sharing Fundamentals

Secure Data Sharing & the Marketplace

Snowflake's most distinctive feature: sharing live data with other accounts in the same region without copying it, and without the recipient needing to be a Snowflake customer at all (through a reader account, next section).

Secure Data Sharing Fundamentals

Definition

A share is a named account-level object granting read-only access to specific databases, schemas, tables, or secure views, to one or more consumer accounts, without copying the underlying micro-partitions. The consumer queries live data directly against the provider's storage. A direct share works only with consumers in the provider's region (listings, two sections on, cross regions).

Direct share inside one cloud region. In the provider account IsmaFrost, SALES_DB holds the data and the provider pays its storage. GRANT statements put USAGE and SELECT into SALES_SHARE, which holds grants and zero bytes. The consumer account creates SHARED_SALES from the share: a read-only database of zero bytes that points at the provider's storage. The consumer's warehouse PARTNER_WH runs the queries, so the consumer pays compute.ONE CLOUD REGION · DIRECT SHARES STAY INSIDE ITPROVIDER ACCOUNT · ISMAFROSTCONSUMER ACCOUNT · PARTNERSHARESALES_SHAREgrants only · 0 bytesDATABASESALES_DBthe data lives hereDATABASE FROM SHARESHARED_SALESread-only · 0 bytesWAREHOUSEPARTNER_WHconsumer's own computereads livedataPays: storagePays: computeGRANT … TO SHAREADD ACCOUNTSruns the queries

ONE CLOUD REGION · DIRECT SHARES STAY INSIDE IT

PROVIDER ACCOUNT · ISMAFROST

CONSUMER ACCOUNT · PARTNER

SHARESALES_SHAREgrants only · 0 bytes

ADD
ACCOUNTS

DATABASE FROM SHARESHARED_SALESread-only · 0 bytes

GRANT … TO SHARE

reads live data

runs the queries

DATABASESALES_DBthe data lives here

WAREHOUSEPARTNER_WHconsumer's own compute

Pays: storage

Pays: compute

Figure 5.5 A direct share moves grants, never data, and only within one region. Follow the green arrows: grants go into the share, then to the consumer, whose read-only database points back at the provider's storage. The provider pays storage, the consumer pays compute.
-- Provider side
CREATE SHARE sales_share;
GRANT USAGE ON DATABASE sales_db TO SHARE sales_share;
GRANT USAGE ON SCHEMA sales_db.public TO SHARE sales_share;
GRANT SELECT ON TABLE sales_db.public.orders TO SHARE sales_share;
ALTER SHARE sales_share ADD ACCOUNTS = consumer_org.consumer_acct;

-- Consumer side: mount the share as a read-only database
CREATE DATABASE shared_sales FROM SHARE provider_org.provider_acct.sales_share;

To let other roles on the consumer side query the shared database, run GRANT IMPORTED PRIVILEGES ON DATABASE shared_sales TO ROLE analyst. It joins with local tables like any other database.

In a direct shareProvider (IsmaFrost)Consumer (partner)
StorageKeeps the data and pays for its storageStores nothing: the database created from the share is 0 bytes
ComputePays nothing for the consumer's queriesQueries with its own warehouse and pays that compute
What is shared, with whomGRANT … TO SHARE, then ALTER SHARE … ADD ACCOUNTSCREATE DATABASE … FROM SHARE
Changing the dataAny change is visible to the consumer immediatelyRead-only: no DML, no clone, no Time Travel; re-sharing only to accounts in its own organization, when the provider allows it
Views in the shareSecure views by default; plain views only in a share created with SECURE_OBJECTS_ONLY = FALSECan't read a secure view's definition

Only secure views (a plain view fits only in a share that allows non-secure objects, and it can leak filtered rows) should sit between raw data and a share when filtering is involved, since a secure view hides its definition and disables optimizer shortcuts that could otherwise leak filtered-out rows to a sufficiently clever consumer query. Masking and row access policies on shared tables are enforced for the consumer too, but a secure view is the usual way to filter rows for a share.