Views of Mysql and views of Mysql
View operations: 1. view creation: create view view_name as query statement; 2. view: show tables; // show all tables and views show create view view_name; desc view_name; show table status from table_name like 'view _ name'; 3. use a view (similar to a query TABLE statement); select * from view_name (where condition); 4. view modification: alter view view_name as query statement; create or replace view view_name as query statement; 5. view deletion: drop view view_name; 6. view classification: (1 ). constant view: create view view_name as select constant; example: create view view_test1 as select 3.1415926; query: select * from view_test1; (2 ). aggregate functions (SUM, MIN ., MAX, COUNT, etc.) query statement view: create view view_name as select function (attribute name) from table_name; example: create view test2 as select count (name) from t_student; (3 ). view of the sorting function: create view view_name as select attribute name from table_name order by attribute name order; the order is divided into DESC and ASC, the former is in descending order, and the latter is in ascending order. (4 ). join query statement in the Table: create view view_name as select attribute from table1_name, table2_name where condition; example: create view view_testt4 as select s. name from t_student as s, t_group as g where s. group_id = g. id and g. id = 2; The as after table_name indicates the alias; (5 ). table Outer JOIN (left join and right join) query statement: create view view_name as select attribute name from table1_name left join table2_name on condition where condition; left join, example: create view view_test5 as select s. name from t_student as s left join t_group as g on s. group_id = g. id where g. id = 2; (6 ). subquery related query statement: create view view_name as select attribute name from table1_name where attribute name in (select attribute name from table2_name); example: create vieww view_test6 as select s. name from t_student as s where s. group_id in (select id from t_group); (7 ). UNION and union all: create view view_name as query statement 1 union all query statement 2; the query content should be the same.