A SQL view is a saved query that behaves like a virtual table. It doesn't store data of its own — every time you query a view, the database runs the underlying query behind it and hands you the result, as if you'd typed that query out in full. Views are one of the simplest ways to make a database easier to work with, especially once your queries start getting complicated.

They're useful in two main situations: when you have a complex query you run often (joins, aggregates, filters) and don't want to retype it every time, and when you want to expose only certain columns or rows of a table to some users without giving them access to the full table.

Creating and Querying a View

Suppose you frequently need to see only the engineering department's employees. Instead of writing the same WHERE clause every time, you can wrap it in a view:

CREATE VIEW engineering_employees AS
SELECT id, name, salary, hire_date
FROM employees
WHERE department = 'Engineering';

Once created, you query it exactly like a table:

SELECT * FROM engineering_employees
ORDER BY salary DESC;

Result:

id | name | salary | hire_date
7 | Priya Nair | 98000 | 2021-03-14
3 | Daniel Osei | 91000 | 2019-11-02
12 | Mei Chen | 87500 | 2022-06-30

Notice the view's own SELECT already filtered to Engineering and picked specific columns — you never had to repeat that filtering logic in the query above. This is the same idea covered in the SELECT statement guide, just packaged for reuse.

Why Use a View Instead of Just the Query?

Three practical reasons come up constantly in real databases:

Reusability. If five different reports all need "active employees in a given department sorted by tenure," defining that once as a view means every report stays consistent, and a future change to the logic only needs to happen in one place.

Simplicity for less technical users. A view built on top of several joined tables can present a single, flat, easy-to-understand result — someone querying it doesn't need to know or care how many tables are involved behind the scenes.

Restricting access. You can grant a user permission to query a view that only exposes certain columns (say, name and department, but not salary), without ever granting them access to the underlying table directly.

Updating and Dropping a View

A view's definition can be replaced without dropping it first, using CREATE OR REPLACE VIEW (supported in PostgreSQL and MySQL):

CREATE OR REPLACE VIEW engineering_employees AS
SELECT id, name, salary, hire_date, department
FROM employees
WHERE department = 'Engineering' AND salary > 50000;

And removing it entirely is just:

DROP VIEW engineering_employees;

One important thing to keep in mind: because a view re-runs its underlying query every time it's accessed, it's always showing live, current data — it's not a snapshot. For most day-to-day reporting and simplification needs, that's exactly the behavior you want.