1. What is a view? A view is an interface for storing data. It can also be said to be a virtual table. These data can be data from one or several base tables (views), or user-defined data. In fact, in the view If the data is not stored, the data still exists in the base table. If the data in the base table changes, the data in the view will also change. If the data in the view changes, the base table will also change.
2. The role of views
1. Views can make queries more convenient (complex SQL statements become very simple)
2. Protect important data in the database and show different data to different people
3. Create View e Create [Orgorithm = {Merge | Temptable | UNDEFINED}]
View view_name [(colorn_list)]
as select_statement
[Cascaded | LOCA l] Check Option]
View has three types
Merge: will combine the text of the statement referencing the view with the view definition, using a certain part of the view definition to replace the corresponding part of the statement
temptable: The result of the view will be placed in a temporary table, and then used Execute the statement.
undefined: MySQL will select the algorithm to use. If possible, it is preferred to MERGE rather than TEMPTABLE, this is because MERGE is usually more efficient, and if a temporary table is used, the view is not updatable
When the user creates the view, mysql By default, a undefine processing algorithm is used, which automatically selects between merge and temporary tables.
With local check option [local] As long as the conditions of this view are met, it can be updated
With cascaded check option [cascaded] All conditions for the view must be met before it can be updated
IV. View The operation
is the same as the table operation
The above has introduced the MySQL view, including Mysql content. I hope it will be helpful to friends who are interested in PHP tutorials.