CodeBlanks Logo Icon CodeBlanks

Summary - VIEW

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

query.sql
-- summary view
CREATE VIEW

Sample solution

query.sql
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

All lessons in Intermediate