Intermediate Topic 19 of 51 Databases
Views
Saved queries presented as virtual tables.
How it works
A view is a stored, named query that behaves like a virtual table; each time it is queried, the database runs the underlying SELECT. Views simplify complex joins, hide columns for security, provide stable interfaces over changing schemas and give consistent definitions to business logic. Materialized views store the result physically and must be refreshed, speeding up expensive reports at the cost of staleness.
Step-by-step walkthrough
- A view stores a query, not data.
- It is built on base tables.
- You query it like a table.
- The database expands the view into the original query.
- Views simplify access and hide sensitive columns.
Where it is used
Reporting layers, row- and column-level access restrictions, compatibility layers during migrations and pre-aggregated dashboards use views.
Common pitfall
Stacked views can hide expensive queries and cause surprising performance. Plain views do not store data or speed anything up by themselves. Updating through a view is limited to simple cases. Materialized views need refresh strategies, and stale data can mislead. Document what each view means, and avoid depending on deeply nested ones.
Where it fits in the course
Views is topic 19 of 51 in Databases, rated Intermediate. It follows Subqueries. The next topic is Indexes.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Databases quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Databases quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Views?
Where do people use Views?
What is the most common mistake with Views?
What should I learn before this topic?
How can I practice it?
Is Views hard to learn?
How long does it take to learn Views?
Which topics are related to Views?
What should I study after Views?
Related topics
- Subqueries (Databases)
- Indexes (Databases)
- Data Types in SQL (Databases)
- Normalization (Databases)