数据库
首页 > 数据库> > mysql 视图

mysql 视图

作者:互联网

视图的好处

重用sql语句,简化复杂语句,屏蔽查询细节

保护数据,用户只看到部分字段

 

视图可以嵌套,可使用order by,不能索引,不能有触发器和默认值

有的视图可以执行更新操作,mysql不支持物化视图

 

 

视图的两种算法

Merge:合并,执行的时候,将视图的sql语句与外部查询语句混合在一起,最终执行

Temptable:临时表,将视图的sql语句生成一个结果表,在结果表中进行查询

 

show create view a 查看创建视图的语句

create view a as select... 创建merge算法的视图

create algorithm = temptable view a... 创建temptable算法的视图

drop view a 删除视图

create or replace [algorithm = temptable] view a 更新视图,也可以先drop再create

 

标签:语句,temptable,create,sql,视图,mysql,view
来源: https://www.cnblogs.com/ts65214/p/12976038.html