A view is an alternative way of representing the data stored in a table. A view can be used to increase the performance of the query since the view contains very limited rows as compared to its source table. We can use the below command to create a view on an existing table TAB1.
CREATE VIEW AGEVIEW (NAME, AGE, ENROLLMENT_ID) AS SELECT NAME, AGE, ENROLLMENT_ID FROM TAB1 WHERE AGE > 10;
We have to use CREATE VIEW reserved words in order to create a new view. This will be followed by the name of the view (AGEVIEW).
The columns which are needed in the view are included in parentheses and these columns are also part of the SELECT SQL statement.
The WHERE clause of the SELECT SQL statement gives the condition which has to be included in a view. In this case, we have added a condition for age greater than 10 years.