SQL · Pattern 13 — Database Objects
Views
A view is a virtual table created from the result of a SQL query.
Source data — Pattern 13: Database Objects
All queries run against the shared employees table (see schema.sql). This pattern introduces commonly used database objects including views, stored procedures, user-defined functions, and triggers. All examples are built using the existing employees table.


What it does
A view is a virtual table created from the result of a SQL query. It simplifies complex queries and improves security by exposing only required data.
Problem
Create a view for active employees.
CREATE VIEW active_employees AS
SELECT *
FROM employees
WHERE status = 'Active';
Result
