Home > database >  MYSQL - view
MYSQL - view

Time:09-22

A,
When a query results need frequent use by other queries to view will be very convenient, the view is formed from the query results of a virtual table,

Two, view create syntax
The create view name as a select statement;

3, the benefits of view
1. Simplify the query;

2. You can access control (there was a table, some of which need access control, data available views to solve);

3. The big data table, in general the number of rows in the table of more than 2 million, are the obvious slow down, then you can put a table data into four tables to store;
The most common modulus, modulus of ID ID % 4 + 1=[1, 2, 3, 4]


Four, view change

Alter the view view_name as a select statement;

5, the relationship between the view and table
View is a table in the query results, if the table with a view will change;
View data update, data table will be updated, only and only if the view with a pair of table data timely (which can be reference function and inverse function) established
View, insert, the view must contain all the no default values in the table column

Six, view the algorithm of
Algorithm=merge/temptable/undefined
Merger: when the reference view, defined statement with the reference view view statements consolidation (means that the view is just a statement rules, when a query view, view the query statements (for example, where those) and create a statement of the where clause merger analysis, such as stroke a select statement
Temptable: when the reference view, according to the view the create statement to create a temporary table (according to create statement instantly create a temporary table, then a query view statements from the temporary table to check data)
Undefined: no custom, let the system automatically choose

CodePudding user response:

Thanks for sharing,
BBS is used to discuss the problem, please notes class knowledge to personal blog,

CodePudding user response:

Thanks for sharing, wrote the blog,
  • Related