SQL CREATE VIEW Statement

Tuesday, January 03, 2012

tags SQL

A SQL view functions as a table but is dynamic in nature. SQL views contain rows and columns just like a table. Views are created from one or more tables that belong to their respective databases.

Syntax



CREATE VIEW viewName AS
SELECT columnName1, columnName2,
FROM tableName


Example



CREATE VIEW newEmployees AS
SELECT employeeID, employeeName, hireDate
FROM Employees
WHERE hireDate > '01/01/2011'


Results



employeeIDemployeeNamehireDate
1745Bob White03/15/2011
2337Jessie Richards07/06/2011

The CREATE VIEW Statement used in this example created a view with three columns from the source table called Employees. You can now use standard SQL Queries to retrieve data from this view.

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

Head First SQL: Your Brain on SQL A Learners Guide SQL Cookbook