SQL CREATE VIEW Statement (original) (raw)

Last Updated : 13 Apr, 2026

The SQL CREATE VIEW statement creates a virtual table based on a SELECT query. It does not store data itself but displays data from one or more tables when accessed.

**Syntax:

CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

Examples of SQL CREATE VIEW Statement

The CREATE VIEW statement in SQL is used to create a virtual table based on the result of a query. Views help simplify complex queries and enhance security by restricting access to specific columns or rows.

Example 1: Creating a Simple View

Consider the table products having three columns product_id, product_name and price. Suppose we have to create a view that contains only products whose prices are greater than $100.

product

**Query:

CREATE VIEW expensive_products AS
SELECT product_id, product_name, price
FROM products
WHERE price > 100;

**Output:

product2

Output of Products priced above 100

Example 2: Creating a Joined View

Assume that we have two tables employees and departments. We need to build a view combining information about both tables in order to show each employee’s name along with their department name:

**Query:

CREATE VIEW employee_department_info AS
SELECT e.employee_id, e.first_name, e.last_name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id;

**Employees table:

emp-11

Employees table

**Departments table:

Sales

Departments table

**Query:

CREATE VIEW employee_department_info AS
SELECT
e.employee_id,
e.first_name,
e.last_name,
d.department_name
FROM employees e
JOIN departments d
ON e.department_id = d.department_id;

**Output:

view

employee_department_info View

**Explanation:

Now, when we query the employee_department_info view, we get a list of employees along with their department names.