0PricingLogin
SQL Academy · Lesson

Plain Views: Logical Reuse

Create views to encapsulate complex queries, simplify reports, and give read access to a subset of columns.

What Is a View?

A view is a saved SELECT. Every time you query the view, the underlying SELECT runs. Like a named query you can JOIN, filter, and aggregate over.

CREATE VIEW active_users AS
  SELECT id, email, full_name
  FROM users
  WHERE deleted_at IS NULL;

Using a View

Query it like any table:

SELECT COUNT(*) FROM active_users;
SELECT * FROM active_users WHERE email LIKE '%@gmail.com';

All lessons in this course

  1. Plain Views: Logical Reuse
  2. Updatable Views and INSTEAD OF Triggers
  3. Materialized Views and REFRESH Strategies
  4. When to Pre-Aggregate
← Back to SQL Academy