Views are database objects that are built by the query. Views can be created using a single table or multiple tables by way of joining.
Their definition is stored permanently in a data dictionary, but they don't save a copy. Data for the view is built dynamically.
A view may contain a subset of the table's rows or a subset of columns.
Create a View
Views are created using a special form of Data Definition Language (DDL). The CREATE requests a new VIEW, provides the name and the SELECT for the view. It is suggested the name of the view either start with "v_" or end with "_v" to identify it as a view name.
That way, it is visibly obvious to people that this is a view and not a table. The name of the view must be unique from the names of other objects in the database. The CREATE VIEW verifies that the name does not already exist and returns an error if it does.
Following is the syntax for creating a view.
Consider the following Employee table.
The following example creates a view on the Employee table.
We can use a regular SELECT statement to retrieve data from Views.
The following example retrieves the records from Employee_View;
A current view can be modified using the REPLACE VIEW statement.
REPLACE VIEW redefines an existing view or, if the specified view does not exist, it creates a new view with the specified name.
Following is the syntax to modify a view.
The following example modifies the view Employee_View for adding additional columns.
A current view can be dropped using the DROP VIEW statement.
Following is the syntax of DROP VIEW.
Following is an example to drop the view Employee_View.
Advantages of Views
Here are some advantages of using Views in Teradata, such as: