什么是视图?
视图可以理解为一张虚拟表,
它是由固定的sql查询语句操作真实表得到的一个临时表
视图不保存数据,视图就保存sql语句,临时执行。
对视图的更新会影响到基本表,在以下几种情况不可以更新视图
1.包含以下关键字的sql语句:聚合函数(sum、min、max、count)、distinct、group by 、having、union或者uinon all
2.常量视图
3.select 中包含子查询
4.join
5.from一个不可更新的视图
6.where字句的子查询引用了from字句中的表
视图的创建,与更新语句
--创建只读视图
create view view_name
as
select * from table_name
with read only
--更新视图
update view_name set name='' where id = ' '