当前位置:网站首页>MySQL view explanation
MySQL view explanation
2022-06-25 18:54:00 【Wind breaking】
What is a view :mysql The view is a section of our Commonly used or complicated Of SQL Statement to save to the view . And alias the view , Each time we call, we can directly call our view method to execute SQL.
Create view :
Case code :
// Create view
CREATE VIEW View name
as
// Query statement
SELECT u.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_id
// Execution view
SELECT * from View name WHERE id=538View modification :
// Modify view Syntax Method 1
create or replace VIEW Modified view name
as
SELECT w.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_id
// Modify view Syntax Method 2
ALTER VIEW View name
as
SELECT w.* from `user` u
LEFT JOIN user_wallet w
ON u.id = w.user_idView and delete views :
// Delete view , Multiple view deletions are separated by commas
DROP VIEW v2;
// View view
// Method 1
DESC View name
// Method 2
SHOW CREATE VIEW View name View SQL Updating and inserting data :
I won't write code cases here , The syntax is the same as the usual insert update , Just change the name to the view name , When inserting and updating views, they are not only operating on view data , It also operates on the data in the original table , The problem to be noted is that if the fields in the original table are not viewed ( Our view also cannot insert data ), Then the data in the original table will appear null , If our field design cannot be empty, view me INSERT Will be abnormal .
The key functions contained in the view that cannot be updated :distinct、group by、baving、union perhaps union all
边栏推荐
- Detailed explanation of oauth2 - Introduction (I)
- Current situation and development suggestions of China's green PPP project industry: the investment scale is expanding, and the existing problems need to be improved to further promote the healthy dev
- Training of long and difficult sentences in postgraduate entrance examination day89
- solidity日期工具
- SQL is used for field data types in various databases
- Problems encountered during the use of pychar
- In 2021, China's private equity market is growing, and the scale of private equity fund management reaches 19.78 trillion yuan [figure]
- Training of long and difficult sentences in postgraduate entrance examination day83
- Cutting feet to fit shoes - talking about the ramp reconstruction on the track
- Training of long and difficult sentences in postgraduate entrance examination day81
猜你喜欢

华为发布两大昇腾计划 推动AI人才发展和科研创新

【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用
![[deeply understand tcapulusdb technology] table management of document acceptance](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[deeply understand tcapulusdb technology] table management of document acceptance
![[deeply understand tcapulusdb technology] cluster management operation](/img/5f/f501f557171d438f7cc9cc4427f234.png)
[deeply understand tcapulusdb technology] cluster management operation

Leetcode-101-symmetric binary tree

利尔达蓝牙空调接收器方案助力打造更舒适的公路生活

Ruffian Heng embedded semimonthly issue 57

158_ Model_ Power Bi uses DAX + SVG to open up almost all possibilities for making business charts

Redis 5.0 data structure double end linked list source code analysis

Class 02 loader subsystem
随机推荐
JS some small problems about adding and accessing values to arrays
Idea annotation color modification method (clear)
Comparison rules of strings in JS
Problems encountered during the use of pychar
华为发布两大昇腾计划 推动AI人才发展和科研创新
Overview and trend analysis of China's CT examination equipment industry in 2021 [figure]
广州华锐互动VR全景为各行各业带来发展
解决sublime Text3 package control 无法安装插件问题
solidity 合约地址转钱包、钱包地址转合约
TCP/IP 测试题(一)
Differences and relations between sequential table and array (easy to confuse), linear table and linked list
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance
Basic operations and basic data types of MySQL database
shell-跳出循环-shift参数左移-函数的使用
[C language practice - print the upper triangle and its deformation (with blank version)]
Leetcode-78-subset
想知道新股民怎样炒股票开户?在线开户安全么?
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
04 program counter (PC register)
Analysis of global tea production, consumption and import and export trade: China's tea production ranks first in the world [figure]