标签:合并 uil 自动 存在 wim dct uek 屏蔽 pemu
优点及缺点
优点
简单化,数据所见即所得
安全性,用户只能查询或修改他们所能见到得到的数据
逻辑独立性,可以屏蔽真实表结构变化带来的影响
缺点
性能相对较差,简单的查询也会变得稍显复杂
修改不方便,特变是复杂的聚合视图基本无法修改
创建视图语法详解
语法结构:
{ CREATE|REPLACE } [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [{column_list}]
AS SELECT_STATEMENT
[WITH [CASCADED | LOCAL |] CHECK OPTION]
释义:
CREATE|REPLACE : 【创建|替换已创建的】视图
ALGORITHM : 视图算法
1.UNDEFINED 系统自动选择算法
2.MERGE使用的视图语句与视图定义合并起来
3.TEMPTABLE 结果存入临时表,然后用临时表执行语句
view_name : 视图名称
column_list : 属性列
SELECT_STATEMENT :SELECT语句
[WITH [CASCADED | LOCAL |] CHECK OPTION] 表示视图在更新时保证在视图的权限范围内
1.CASCADED 默认值 更新视图时要满足所有相关视图和表的条件,2.LOCAL表示更新视图时满足该视图本身定义的条件即可。
示例用表
1 select a.name as username, b.name as goodsname from user as a, goods as b, ug as c where a.id=c.userid and c.goodsid=b.id;
1 create view other as select a.name as username, b.name as goodsname from user as a, goods as b, ug as c where a.id=c.userid and c.goodsid=b.id;
1 create view user as select a.name,a.age,b.sex from usera as a, userb as b where a.name=b.name;
1 create view other as select a.name, a.age from user as a;
标签:合并 uil 自动 存在 wim dct uek 屏蔽 pemu
原文地址:https://www.cnblogs.com/guliang/p/11698032.html