当前位置:网站首页>mysql视图基本操作
mysql视图基本操作
2022-07-27 16:12:00 【zkkkkkkkkkkkkk】
mysql视图介绍及如何创建视图请看:一个案例理解mysql视图。本章主要记录视图的修改、删除以及展示视图语法。
目录
一、创建视图
二、修改视图
语法:alter view view_name as 修改内容
--语法 alter view view_name as
-- 内容
alter view sms as
select s_id,s_name
from student
译:将以sms命名的视图内容修改为student表中的s_id和s_name三、删除视图
语法:drop view view_name(可搭配 if exists 使用,语法:drop view if exists view_name)
-- 语法1 drop view view_name
drop view sms
-- 语法2 drop view if exists view_name
drop view if exists sms
四、更新视图
同样的视图也可以像真实的表一样更新数据,但是值得注意的是更新视图里的数据,也相当于对真实的表做了更新
语法:UPDATE view_name set update_columns where 条件
# 创建视图学生表
create view view_student as
select *
from student
-- 更新视图
update view_student set s_id = 888 where s_name = '张三'
将上述sql执行完毕之后,我们再打开两张表(视图表 view_student,真实表student)。我们会发现这两张表满足上述where条件都会更改,也就是说更新视图会影响真实表里的原数据。
下面是执行更新视图语句前后的结果截图:
原始student和view_student 更新后student 更新后view_student

五、展示视图
语法:show create view view_name(用来查询某个视图的详细信息)
-- 语法:show create view view_name
show create view sms
输出如下图所示:

边栏推荐
- rsa加解密(兼容微信小程序环境)
- [MIT 6.S081] Lab 9: file system
- 2021.7.17 notes MySQL other commands
- [MIT 6.S081] Lec 9: Interrupts 笔记
- [MIT 6.S081] Lec 6: Isolation & system call entry/exit 笔记
- Mybtis-Plus常用的内置方法
- @Convert 注解在jpa中进行查询的注意事项
- 2021.8.1笔记 DBA
- 2021.7.28 notes
- Deep learning - VIDEO behavior recognition: paper reading - two stream revolutionary networks for action recognition in videos
猜你喜欢
![[MIT 6.S081] Lab 5: xv6 lazy page allocation](/img/f6/8b619412bc6ba425d0f04629917e80.png)
[MIT 6.S081] Lab 5: xv6 lazy page allocation

2. 改变颜色空间及颜色检测

2021.7.12笔记 内外连接

2. Change color space and color detection

Deep learning: a survey of behavior recognition
![[mit 6.s081] LEC 5: calling conventions and stack frames risc-v notes](/img/1f/6384f4831718477f0567540250f352.png)
[mit 6.s081] LEC 5: calling conventions and stack frames risc-v notes

Super practical! After reading the kubernetes study notes hidden by Alibaba P9, call NB directly

2021.7.17 notes MySQL other commands

2021.7.30笔记 索引

发布自己的npm组件库
随机推荐
2021.7.31 note view
Publish your own NPM component library
2021.7.19笔记 DML
2021.7.22笔记 约束
[mit 6.s081] LEC 3: OS organization and system calls notes
Uniapp has no effect on the page selector on the app side
深度学习:GAN案例练习-minst手写数字
@Considerations for query of convert annotation in JPA
2021.8.9笔记 request
Announcing the acquisition of 30% shares of Wenye, what is the general intention of Dalian United?
[mit 6.s081] LEC 8: page faults notes
multi-table query
LootCode动态数组练习(724,118,766)
Deep learning: gat
[MIT 6.S081] Lec 8: Page faults 笔记
Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!
Technology sharing | quick intercom integrated dispatching system
Deep learning: stgcn learning notes
Deep learning - VIDEO behavior recognition: paper reading - two stream revolutionary networks for action recognition in videos
深度学习:安装包记录