A view in SQL as a logical subset of data from one or more tables. Views are used to restrict data access. A view does not contain its own data, but contains a window-like window through which you can view or change data in a table. The table on which the view is based is called the base table.
There are two types of views in SQL: simple views and complex views.
Simple views can only contain a single base table. Complex views can be constructed on multiple base tables.
Complex views can include: connection conditions, group by clause, order by clause.
The main differences between these views are:
Simple View | Complex View |
Contain only one base table or create from only one table. | Contains multiple base tables or creates from multiple tables. |
We cannot use group functions like MAX(), COUNT() etc. | We can use group functions. |
Does not contain data groups. | It protects data groups. |
DML operations can be performed through simple views. | DML operations cannot always be performed through complex views. |
INSERT, DELETE and UPDATE can be executed directly on the simple view. | We cannot apply INSERT, DELETE and UPDATE directly on complex views. |
Simple view does not contain group by, distinct, pseudocolumn such as rownum, columns defiend by expressions. | It can contain group by, distinct, pseudocolumn such as rownum, columns defiend by expression. |
Do not include NOT NULL columns in the base table. | NOT NULL columns that are not selected by a simple view can be included in a complex view. |
Recommended study: "mysql tutorial"
This article is an introduction to the difference between simple views and complex views in SQL. Hope it helps those in need!
The above is the detailed content of The difference between simple views and complex views in SQL. For more information, please follow other related articles on the PHP Chinese website!