Home / Learn Secure SQL / Views: Saved Queries

Views: Saved Queries

A named, reusable SELECT.

Quick summaryA named, reusable SELECT.

How to think about this

A viewCREATE VIEWstores a SELECTquery it like a table
A view

Definition

A view is a stored SELECT statement that you can query as if it were a table.

Why you need this

Views simplify repeated complex queries and, used well, can restrict which columns an account is allowed to see (more in the access control part).

How it works

CREATE VIEW name AS SELECT ...; then SELECT * FROM name like any table.

Where you'll see this

  • Web application code review
  • Backend development
  • Database administration
A simple viewSQL: edit and run

Querying the view re-runs the underlying SELECT.

Test what you just read

1. A view is best described as...