What is a View in SQL?
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table.
The basic CREATE VIEW syntax is as follows:
CREATE VIEW view_name AS SELECT column1, column2.....FROM table_nameWHERE [condition];
Following is an example to create a view from the SLIGHTBOOK table. This view would be used to have a SLIGHTBOOK courseid, course, and duration from the SLIGHTBOOK table.
CREATE VIEW SLIGHTBOOK_VIEW AS SELECT courseid, course, duration FROM ?SLIGHTBOOK;
Now, you can query SLIGHTBOOK_VIEW in a similar way as you query an actual table. Following is an example of the same,
SELECT * FROM SLIGHTBOOK_VIEW;
What is the use of Cross Join in SQL?
What is the use of Full Join in SQL?
What are the properties of a transaction in SQL?
Which is not the properties of a transaction in SQL?
What is the use of Session Control Statement(SCS) in SQL?