当前位置:网站首页>mysql视图讲解
mysql视图讲解
2022-06-25 18:21:00 【破 风】
什么是视图 :mysql视图是将我们的一段常用或者复杂的的SQL语句进行保存到视图里面。并且给视图取上别名,每次我们调用的时候可以直接调用我们视图方法进行执行SQL。
创建视图:
案例代码:
//创建视图
CREATE VIEW 视图名
as
//查询语句
SELECT u.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_id
//执行视图
SELECT * from 视图名 WHERE id=538视图修改 :
//修改视图语法 方法一
create or replace VIEW 修改的视图名
as
SELECT w.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_id
//修改视图语法 方法二
ALTER VIEW 视图名
as
SELECT w.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_id查看与删除视图 :
//删除视图,多个视图删除用逗号隔开
DROP VIEW v2;
//查看视图
//方法一
DESC 视图名
//方法二
SHOW CREATE VIEW 视图名视图SQL数据的更新与插入:
这里我就不写代码案例了,语法和平时的插入更新是一样的,只是名字换成视图名字,视图的插入与更新的话他不单是对视图的数据进行操作,还会对原始表里面的数据进行操作,需要注意的问题是如果原始表里面的字段没有进行视图的话(我们视图也无法插入数据),那么原始表里面的数据会出现null ,如果我们字段设计的不能为空的话视图我INSERT将会异常。
不能进行更新的视图里面包含的关键函数:distinct、group by、baving、union或者union all
边栏推荐
- [in depth understanding of tcapulusdb technology] how to realize single machine installation of tmonitor
- Dell r530 built in hot spare status change description
- 158_模型_Power BI 使用 DAX + SVG 打通制作商業圖錶幾乎所有可能
- Network security algorithm
- RMAN备份数据库_跳过脱机,只读和不可访问的文件
- Trample hole record -- a series of coincidences caused by thread pool rejection policy
- 【路径规划】如何给路径增加运动对象
- [in depth understanding of tcapulusdb technology] new models of tcapulusdb
- Basic operation details of binary search tree (BST) (complete code, including test cases)
- Idea annotation color modification method (clear)
猜你喜欢

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩

. How to exit net worker service gracefully

正则表达式总结

初探Oracle全栈虚拟机---GraalVM

【深入理解TcaplusDB技术】TcaplusDB导入数据

【深入理解TcaplusDB技术】单据受理之创建业务指南

Ruffian Heng embedded semimonthly issue 57

Kwai 616 war report was launched, and the essence was thrown away for the second time to lead the new wave. Fast brand jumped to the top 3 of the hot list

【ELT.ZIP】OpenHarmony啃论文俱乐部—见证文件压缩系统EROFS
![[elt.zip] openharmony paper Club - memory compression for data intensive applications](/img/54/8248c1d95b04498d44a00ea94a6c85.png)
[elt.zip] openharmony paper Club - memory compression for data intensive applications
随机推荐
RMAN备份数据库_双重备份备份集(Duplexing Backup Sets)
【深入理解TcaplusDB技术】单据受理之表管理
【深入理解TcaplusDB技术】单据受理之事务执行
Kwai 616 war report was launched, and the essence was thrown away for the second time to lead the new wave. Fast brand jumped to the top 3 of the hot list
Anaconda download Tsinghua source
LeetCode力扣(剑指offer 26-30)26. 树的子结构 27. 二叉树的镜像 28. 对称的二叉树 29. 顺时针打印矩阵 30. 包含min函数的栈
Move graph explorer to jupyterab: use ges4jupyter to connect ges and explore graphs
. Net worker service adding a serial log record
el-table高度自适应
Meaning of% in C language
中金财富安全吗? 开户需要多久
Command records of common data types for redis cli operations
C ASP, net core framework value transfer method and session use
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
[deeply understand tcapulusdb technology] create a game area for document acceptance
What is an operator?
Redis command string
【深入理解TcaplusDB技术】TcaplusDB运维
solidity获取季度时间
158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能