Summary - VIEW
- SQL course
- Intermediate
- Lesson 76/115
- 5 min
Store a complex query as a view and reuse it.
Summary - VIEW
A VIEW is a virtual table. Created with CREATE VIEW, queried with SELECT, removed with DROP VIEW.
CREATE VIEW active_customers AS
SELECT * FROM customers WHERE status = 'active';Summary VIEW query.
The view active_customers is created. All columns are selected from customers. WHERE keeps only the rows where status = 'active' holds.
Practice Summary - VIEW
Summary: create the active_customers VIEW.
Starter code
-- summary view
CREATE VIEWSample solution
CREATE VIEW active_customers AS
SELECT * FROM customers WHERE status = 'active';Expected output
VIEW oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does a VIEW store?
- The data
- Everyone
- The query Correct answer
- An index
Explanation: A VIEW stores the query.
2 Summary - VIEW: match the terms
| Term | Meaning |
|---|---|
VIEW |
virtual table |
CREATE VIEW |
create |
DROP VIEW |
remove |
SELECT |
query |