当前位置:网站首页>【mysql学习笔记26】视图
【mysql学习笔记26】视图
2022-07-01 07:30:00 【yqs_281876918】
创建视图
CREATE VIEW view_name[(col1,col2,…)] AS SELECT语句 [WITH [CASCADED|LOCAL] CHECK OPTION];
查询视图
查看创建语句
show create view 视图名;
查询
select * from 视图名;
修改视图
方式一
CREATE OR REPLACE VIEW view_name[(col1,col2,…)] AS SELECT语句 [WITH [CASCADED|LOCAL] CHECK OPTION];
方式二
ALTER VIEW 视图名(列明列表) AS SELECT语句 [WITH [CASCADED|LOCAL] CHECK OPTION];
删除视图
DROP VIEW [IF EXISTS] 视图名;
插入
对视图进行插入会插入原表中
检查选项
当使用WITH CHECK OPTION子句创建视图时,MySQL会通过视图检查正在更改的每个行,例如插入,更新,删除,以使其符合视图的定义。MySQL允许基于另一个视图创建视图,它还会检查依赖视图中的规则以保持一致性。为了确定检查的范围,mysql提供了两个选项:CASCADED和LOCAL,默认值为CASCADED。
无with check option时,是不需要满足当前视图的条件的。并且对于底部视图(即该视图针对的视图),先判断底部视图是否有with check option语句,有的话,按照其规则(local或者cascaded)处理,没有的话则不需要满足底部视图的条件。
with local check option时,需要满足当前视图的条件。对于底部视图,也是先看是否有指定的with check option语句,有的话对应处理,无则不需要满足底部视图的条件。
with cascaded check option(cascaded可以省略)时,需要满足当前视图的条件。并且对于所有底部视图的条件,也需要一并满足,哪怕底部视图没有定义with check option语句。
更新
要使得视图可更新,那么视图的列必须和原表的列一一对应
边栏推荐
- Detailed explanation of weback5 basic configuration
- go-etcd
- How to enter the Internet industry and become a product manager? How to become a product manager without project experience?
- 运维管理有什么实用的技巧吗
- C# Newtonsoft. Use of job in JSON
- [classification model] Q-type cluster analysis
- JAX的深度学习和科学计算
- 未来互联网人才还稀缺吗?哪些技术方向热门?
- Is it safe and reliable for Huatai Securities to open an account? How to open Huatai Securities Account
- How to create an exclusive vs Code theme
猜你喜欢

MATLAB之基础知识

Microsoft announces open source (Godel) language model chat robot
![[target detection] yolov5, the shoulder of target detection (detailed principle + Training Guide)](/img/47/80d2e92ea7347cc5c7410194d5bf2e.png)
[target detection] yolov5, the shoulder of target detection (detailed principle + Training Guide)

1286_FreeRTOS的任务优先级设置实现分析

Apple account password auto fill

ctfshow-web351(SSRF)

Eigen矩阵运算库快速上手

Illusory and simple screen raindrop post-processing effect

【剑指offer&牛客101】中那些高频笔试,面试题——链表篇

2022 electrician (intermediate) recurrent training question bank and answers
随机推荐
Inftnews | from "avalanche" to Baidu "xirang", 16 major events of the meta universe in 30 years
Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
Discussion on several research hotspots of cvpr2022
Redisson uses the full solution - redisson official document + comments (Part 2)
Minecraft 1.16.5 module development (51) tile entity
Why are so many people turning to product managers? What is the development prospect of product manager?
[network planning] (I) hub, bridge, switch, router and other concepts
C language implementation [Sanzi chess game] (step analysis and implementation source code)
Is the account opening of GF Securities safe and reliable? How to open GF Securities Account
三极管是一项伟大的发明
【深圳IO】精确食品称(汇编语言的一些理解)
关于“2022年度网络安全教育线上培训”相关问题的复盘和说明
[programming compulsory training 3] find the longest consecutive number string in the string + the number that appears more than half of the times in the array
Paging in servlets and JSPS
C language implementation [minesweeping game] full version (implementation source code)
redisson使用全解——redisson官方文檔+注釋(上篇)
Understanding of Turing test and Chinese Room
Félicitations pour l'inscription réussie de wuxinghe
Todolist classic case ①
go-etcd