先决条件 – SQL |观看次数
SQL 中的视图,作为来自一个或多个表的数据的逻辑子集。视图用于限制数据访问。视图不包含其自身的数据,但包含类似窗口,通过该窗口可以查看或更改表中的数据。视图所基于的表称为基表。
SQL 中有两种类型的视图:简单视图和复杂视图。简单视图只能包含一个基表。可以在多个基表上构建复杂视图。特别是,复杂视图可以包含:连接条件、group by 子句、order by 子句。
这些类型的视图之间的主要区别是:
Simple View | Complex View |
---|---|
Contains only one single base table or is created from only one table. | Contains more than one base tables or is created from more than one tables. |
We cannot use group functions like MAX(), COUNT(), etc. | We can use group functions. |
Does not contain groups of data. | It can contain groups of data. |
DML operations could be performed through a simple view. | DML operations could not always be performed through a complex view. |
INSERT, DELETE and UPDATE are directly possible on a simple view. | We cannot apply INSERT, DELETE and UPDATE on complex view directly. |
Simple view does not contain group by, distinct, pseudocolumn like rownum, columns defiend by expressions. | It can contain group by, distinct, pseudocolumn like rownum, columns defiend by expressions. |
Does not include NOT NULL columns from base tables. | NOT NULL columns that are not selected by simple view can be included in complex view. |
参考 –
查看 – orafaq