MySQL + SQL · Lesson 93
Views in MySQL
What is a View?
A view is a saved query that behaves like a virtual table. It does not store data itself — it shows live data from the underlying tables each time you query it.
Creating a View
CREATE VIEW toppers AS
SELECT name, marks FROM students WHERE marks >= 90;
-- use it like a table
SELECT * FROM toppers;Every time you query "toppers", it runs the saved SELECT on current data.
Why Use Views?
- Hide complex joins behind a simple name.
- Show users only certain columns (security).
- Reuse a common query everywhere.
Removing a View
DROP VIEW toppers;
Summary
- A view is a saved query acting as a virtual table.
- It stores no data; it shows live results from base tables.
- Good for simplifying queries and limiting access.