Snowflake Views

Snowflake · Views, Pipelines & Automation

Theory

A view is a named SELECT that you query like a table. A standard view stores only the query text and runs it each time it is queried, so it always reflects current data and costs nothing to store. A secure view hides its definition from users who do not own it and blocks optimizations that could reveal hidden rows, which is why it is required when sharing views with other accounts. A materialized view stores the precomputed result and a background service keeps it up to date as the base table changes.

For example, v_active_customers can wrap a WHERE is_active = TRUE filter, while mv_daily_revenue precomputes daily totals over a huge orders table.

Why we use it

Views let you reuse logic, simplify queries for users and control what columns and rows are exposed. Materialized views add speed for expensive, repeated aggregations on large tables.

When to use it

Use standard views for reusable logic, secure views when the definition or underlying data must be protected or shared, and materialized views (Enterprise edition) for frequent, costly queries on a single table that changes less often than it is read.

Standard Views

Re-run their underlying query every time they're queried, so they always reflect current data but add the query's cost each time.

Secure Views

Additionally hide their query definition and internals from users who can query them — useful for masking business logic or sensitive join conditions.

Materialized Views

Precompute and physically store their result, trading storage and a small refresh cost for much faster reads — best for expensive aggregations queried often but changing rarely.

How it works

  1. Need to expose or reuse a query
  2. Must the definition or hidden data be protected, or is it shared? Yes: Create a SECURE view. No: Consider a standard view.
  3. Is it an expensive, frequent query on one large table? Yes: Create a MATERIALIZED view. No: Use a standard view.
  4. Grant SELECT on the view, not the base table
  5. Users query the view like a table

Example

CREATE OR REPLACE VIEW v_active_customers AS
SELECT customer_id, first_name, email FROM customers WHERE is_active = TRUE;

CREATE OR REPLACE SECURE VIEW v_customer_summary AS
SELECT state, COUNT(*) AS customer_count FROM customers GROUP BY state;

CREATE OR REPLACE MATERIALIZED VIEW mv_daily_revenue AS
SELECT order_date, SUM(amount) AS total_revenue FROM orders GROUP BY order_date;

Key points

Snowflake topics

Snowflake Fundamentals

Warehouses & Performance

Staging & SnowSQL

Tables & Data Handling

Cloud Integrations

Storage & Optimization

Security & Governance

Views, Pipelines & Automation

Data Types & SQL Fundamentals

Semi-Structured Data Deep Dive

Advanced Features

Data Sharing & Collaboration

Cost Management & Monitoring

Databases, Schemas & Objects

Performance Deep Dive

Advanced Security & Governance

Stored Procedures & UDFs

Ecosystem & Integrations

SnowPro Certification Prep

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Mastering Snowflake

The modern data cloud, from architecture to SnowPro certification. Click any topic in the sidebar to open it right here.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice Snowflake SQL Sharpen the SQL you use in Snowflake: 150 query problems in a live editor with instant checking. Start practising →
Section {{ sec.num }}

{{ sec.label }}

Snowflake  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

{{ sec.h }}

{{ sec.body }}

{{ sec.body }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
On screen — where to click

{{ rich.ui.title }}

{{ u.text }}
  1. {{ st.n }}{{ st.text }}
{{ rich.ui.title }}
{{ u.text }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax
{{ current.syntax }}
Example
{{ current.example }}
Want to run this yourself? Unlike the SQL and Python courses, Snowflake needs a real account — there's no in-browser engine for it. Click Copy above, then paste it into a free Snowflake trial (30 days, no card required) and run it in Snowsight.
Key Points — click to check off as you learn
  • {{ pt.mark }} {{ pt.text }}

Share this topic