Views

Lesson 16 of 20

Save a query under a name and query it like a table — watch CREATE VIEW and a SELECT from the view run.

The big picture

A saved query wearing a table costume

A view is a SELECT statement stored in the database under a name. Query the view, and the engine quietly runs the stored query for you.

CREATE VIEW

CREATE VIEW name AS SELECT ... saves the query text. No rows are copied anywhere.

Virtual table

The view holds a query, not data — that is why people call it a virtual table.

Always current

Every query against the view re-runs the stored SELECT, so results always reflect fresh data.

Simplify and protect

Views hide complex joins behind one name, and expose only the columns callers should see.