1, a view description:
(ps: school sqlServer view is learned after the interview asked, and could not answer too low, and then went to various search operations on the view also have their own understanding)
actually view is a table, a single table or multiple tables after some data show that after the screening, the view is a predefined query select statements, for the simple
view is that aspect is designed to let the viewing data, operate their view if not the original data table change so relatively safe, or else a database has many tables
all to see will be very troublesome, view lets multiple tables make up a new table, this is the view, the view of the data can not add, delete, change operation.
1.1 Role of view of:
- Hidden from view the underlying table structure, simplifies data access operations, client no longer needs to know the relationship between structure and underlying tables.
- View provides a unified interface to access the data. (I.e., users may be allowed access to view the data security, without giving the user direct access to the underlying table)
- Thereby strengthening the security, so that users only see the data displayed view.
- May also be nested view, a view can be nested in another view.
2. Create view syntax:
2.1, the view to create, delete, view
Database view the situation:
2.2 of view to be modified:
3, inserting data into view
In addition to recording the query view, the view may also be used to insert, update, delete a recording operation, to reduce the direct manipulation of the base table information to improve the data security.
PS:
- 视图不能包含 ORDER BY 子句,除非SELECT语句的选择列表中还有一个 TOP 子句。
- 视图不能使用 INTO 关键字。视图不能包含 OPTION 子句。
- 视图不能有对临时表或表变量的引用。视图最多可以有 1024 列。