Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 38 ยท Security and Governance

Secure Views, Secure Data Sharing and Governance

Learn secure views, secure data sharing with shares and reader accounts, the Marketplace, and governance tools: access history, object tags and data lineage.

Data has value when other people can use it, and risk when the wrong people can. Snowflake lets you share live data without copying it, and gives you tools to prove who touched what. This lesson covers secure views (the safe way to expose a subset), secure data sharing across accounts, and the governance features that tie it together.

Sharing needs two Snowflake accounts, so the Snowflake statements below are read-only. The views and filtering logic that make sharing safe are demonstrated with runnable SQL in SQLite.

Regular views versus secure views

A normal view hides columns and rows, but a clever user may learn about the hidden data from the view definition or from how the optimizer handles the query (for example by crafting a filter that errors on hidden values). A secure view closes those gaps:

  • its definition is visible only to roles that own it, not to every role that can query it,
  • the optimizer does not push user predicates below the view's own filters in ways that could leak data.
SQL
CREATE SECURE VIEW sales.public.eu_orders AS
SELECT order_id, order_date, amount, region
FROM sales.public.orders
WHERE region = 'EU';

The price is some lost optimization, so secure views can be slower than ordinary ones. Use them whenever a view is the security boundary: for shares, for contractors and for any role that must not see the rest of the table.

SQL A view as a security boundary (stand-in) ยท database: shop

Press Run (or Ctrl + Enter) to see the result here.

The partner sees order values by reference, with no customer, no cancelled orders and no line items. In Snowflake, you would create this as a SECURE VIEW and share it.

Secure data sharing

Normally sharing data means exporting files and trusting copies. In Snowflake, a provider account creates a share, a named object that points at databases, schemas and tables or secure views. A consumer account creates a read-only database from the share. No data is copied or moved: the consumer queries the provider's storage, using the consumer's own warehouse and paying only for that compute.

flowchart LR
  subgraph P["Provider account"]
    T["Tables and secure views"] --> S["SHARE"]
  end
  subgraph C["Consumer account"]
    D["Read-only database<br/>created from share"] --> Q["Consumer warehouse<br/>runs queries"]
  end
  S -. "metadata only,<br/>no copy" .-> D

The consumer sees live data; the provider can revoke access instantly.

Provider side:

SQL
CREATE SHARE partner_share;
GRANT USAGE  ON DATABASE sales                  TO SHARE partner_share;
GRANT USAGE  ON SCHEMA   sales.public           TO SHARE partner_share;
GRANT SELECT ON VIEW     sales.public.eu_orders TO SHARE partner_share;   -- secure view
ALTER SHARE partner_share ADD ACCOUNTS = partner_org.partner_account;

Consumer side:

SQL
CREATE DATABASE partner_sales FROM SHARE provider_org.provider_account.partner_share;
GRANT IMPORTED PRIVILEGES ON DATABASE partner_sales TO ROLE analyst;
SELECT * FROM partner_sales.public.eu_orders;

Things to know:

  • Shares are read-only for consumers. They can query and join with their own data, but not change shared objects.
  • Only secure views (and tables, secure materialized views, secure UDFs) can be added to a share.
  • A reader account lets you share with a party that has no Snowflake account: you create and pay for the account, and the partner uses it.
  • Data exchange and the Marketplace let you publish listings (free or paid) to many consumers. Listings can include live data, apps and auto-fulfillment across regions.
  • Sharing across regions or clouds uses replication under the hood, which has a transfer cost.
  • Data clean rooms let two parties join their data and learn only agreed aggregate results, with neither side seeing the other's rows.

Replication and failover (a note)

Databases can be replicated to other accounts, regions or clouds, and replication groups can fail over for business continuity. This sits beside sharing: sharing gives others read access to your data; replication gives you a second copy.

Governance: knowing what happened

Security controls are half of governance. The other half is evidence.

Feature Question it answers
ACCESS_HISTORY Which columns and tables did each query read or write?
QUERY_HISTORY Who ran which SQL, when, on which warehouse?
LOGIN_HISTORY Who signed in, from where, with which factor?
POLICY_REFERENCES Which objects carry which masking or row access policy?
TAG_REFERENCES Which objects carry which tag (for example pii)?
Object dependencies Which views depend on this table?
Lineage (Snowsight) Where did this data come from, and what uses it?

A useful audit query joins access history to tags: "show every query in the last 30 days that read a column tagged pii, grouped by role".

SQL An audit question as SQL (stand-in) ยท database: company

Press Run (or Ctrl + Enter) to see the result here.

The real ACCESS_HISTORY stores the columns as a JSON array, which you would flatten with LATERAL FLATTEN (see semi-structured data in the querying chapter of this course); the join idea is the same.

A governance checklist

  1. Classify and tag sensitive columns; attach masking by tag.
  2. Share only through secure views, and review shares regularly (SHOW SHARES).
  3. Keep ownership with stable roles, grant access through access roles.
  4. Monitor login, access and query history; alert on unusual volume or new locations.
  5. Document data owners and keep lineage current.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why use a secure view rather than a normal view for a share?

    Secure views hide their definition from consumers and prevent optimizer-based leaks.
  2. 2. When a consumer queries shared data, whose compute is used?

    The consumer queries the provider's storage but pays for their own warehouse.
  3. 3. How can you share with a company that has no Snowflake account?

    A reader account is a Snowflake account you provision and pay for, giving the partner read access.
  4. 4. Which view tells you which columns a query read?

    ACCESS_HISTORY records objects and columns read or written by each query.

Summary

  • Secure views are the safe boundary for exposing a subset of data.
  • Shares give consumers live, read-only access to provider data with no copying.
  • Reader accounts, the Marketplace and clean rooms extend sharing.
  • Governance relies on history views, tags, policy references and lineage.

Next: Streams and change data capture