Database Basics View

1. Definition: A view is a virtual table whose content is defined by a query. A view contains a series of named columns and rows of data that does not exist in the database as a set of stored data values ​​(except for indexed views). Row and column data comes from tables referenced by the query that defines the view, and is dynamically generated when the view is referenced.

2. Personal understanding:
① The data corresponding to the view is not actually stored. Only the definition of the view is stored in the database. When operating the data of the view, the system operates the basic table associated with the view according to the definition of the view.
② The role of the view is similar to filtering. A filter that defines a view can come from one or more tables in the current or other databases, or other views.
③ Distributed queries can also be used to define views using data from multiple heterogeneous sources.
④ When modifying the data seen through the view, the data of the corresponding basic table will also change. At the same time, if the data of the basic table changes, the change can also be automatically reflected in the view.

3. Function:
Simplicity: Simplify the user's understanding and operation of the view.
Security: Through the view, users can only query and modify the data they can see.
Logical independence: Views can help users shield the impact of changes in the real table structure (in some cases, due to the large amount of data in the table, the table is often divided horizontally or vertically in the design of the table, but the structure of the table is not. However, the changes have adverse effects on the application. If the view is used, the original structural relationship can be re-maintained, so that the external schema remains unchanged, and the original application can still reload the data through the view.)

4. Syntax :
CREATE VIEW ViewName
AS
select ...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325762876&siteId=291194637