Views
A view is a saved query that behaves like a table — you can SELECT from it just like a real one, but under the hood it's just running the query it was defined with, every time.
Creating a view
Say you're constantly running the same join to see employees alongside their department's location. Instead of retyping it, save it as a view:
From here on, employee_locations can be queried, filtered, and sorted exactly like a table:
Why bother?
- It saves you from retyping — and mistyping — the same complex query.
- It can hide complexity from people or tools that only need the simplified shape.
- It always reflects live data, since it re-runs the underlying query each time you use it.
Course complete: that's the SQL course — reading data with
SELECT, filtering, sorting, aggregating, changing data, joins, creating tables, pattern matching, NULLs, subqueries, UNION, constraints, and views. Together these cover the vast majority of what you'll actually write day to day working with a database.