mysql視圖
1. 視圖可以叫sql語句更簡單
2. 保護(hù)數(shù)據(jù)給不同的人看不同的數(shù)據(jù)
create view view_table ?as select *from table_name;
creaate view stu asselect a.name,a.age,a.email,a.phone,b.phpc,b.javac,b.oraclec from student a,score b where a.id=b.sid;
create [or replace] [algorithm={merge|temptable|undefined}]
view view_name [(column_list)]
as select_statement
[with [cascaded|local] check option]
視圖有三種類型
Merge:會將引用視圖的語句的文本與視圖定義結(jié)合起來挥转,使用得視圖定義的某一部分取代語句對應(yīng)部分
Temptable
undefined 沒有指定默認(rèn) merge
algorithm=merge
with local check option ? with[local]只要滿足本視圖的條件就可以更新
with cascaded check option ?with [cascaded]必須滿足所有針對視圖的條件,才可以跟新
操作視圖
alter view student_view as select *from student
drop view stu..,視圖
show table status like 'stu2'/G'
show create view stu/G