CREATE VIEW
Creates a virtual table whose contents (columns and rows) are defined by a query. Use this statement to create a view of the data in one or more tables in the database. For example, a view can be used for the following purposes:
- To focus, simplify, and customize the perception each user has of the database.
- As a security mechanism by allowing users to access data through the view, without granting the users permissions to directly access the underlying base tables.
- To provide a backward compatible interface to emulate a table whose schema has changed.
Example:
Create View Customer_view
AS
Select customerid, customername,city from customers
The above statement will create a view named customer_view
To Alter view:
Example:
Alter view customer_view
As
Select customerid, customername,city,country from customers