Skip to main content
Module 9 · Lesson 4 of 436/57 in the course~15 min
Module lessons (4/4)

Views and Data Abstraction

Lesson preview5 hands-on exercises readySQL Course · Module 9 — Data Structures and DDL

Use VIEWs to encapsulate complex queries and MATERIALIZED VIEWs to cache heavy reads.

What you'll learn in this lesson

  • Save complex queries under a reusable name using CREATE VIEW (and CREATE OR REPLACE VIEW).
  • Distinguish a standard View (calculated in real time, never stale data) from a MATERIALIZED VIEW (snapshot on disk to be updated with REFRESH).
  • Use views to encapsulate JOIN/GROUP BY logic and protect sensitive columns.

Overview

When the same combination of JOIN, filters, and GROUP BY reappears in dozens of dashboards and microservices, duplicating it everywhere becomes risky. A View (VIEW) gives a persistent name to a SELECT allowing you to query it exactly as if it were a normal table!

A VIEW containing JOIN and GROUP BY does not pre-calculate the table: at each reading the planner merges your SELECT * FROM vista WHERE ... with the pipeline of JOIN, WHERE and GROUP BY defined in the view itself:

Sections covered in this lesson

  1. 11. Mental Model: Virtual View vs Materialized View
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Laboratory: What a View Does Behind the Scenes
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 9 — Data Structures and DDL

Unlock "Views and Data Abstraction" and the full SQL Course curriculum

Use VIEWs to encapsulate complex queries and MATERIALIZED VIEWs to cache heavy reads.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.