Table of contents
3. View rules and restrictions
1. View introduction
A view is a virtual table whose contents are defined by queries. Like a real table, a view contains a series of named columns and rows of data. Data changes in the view will affect the base table, and data changes in the base table will also affect the view .
2. Basic use
Create a view:
create view 视图名 as select语句;
Case:
It also proves that the view is also a table, and it can also be queried in the data after it is created.
The view is modified, which affects the base table data:
The base table is modified, which affects the view:
Delete a view:
drop view 视图名;
3. View rules and restrictions
- Like tables, they must be named uniquely (views or table names with the same name cannot appear)
- There is no limit to the number of views created, but the performance impact of creating complex queries as views must be considered.
- Views cannot have indexes added, nor can they have associated triggers or default values.
- Views can increase security and must have sufficient access rights
- order by can be used in a view, but if the data select retrieved from the view also contains order by, the order by in the view will be overwritten.
- Views can be used with tables