当前位置:网站首页>MySQL view
MySQL view
2022-07-25 16:37:00 【Sooner or later, I will go bald】
One 、 Create view
grammar :
create view View name
as
Query statement ;
USE myemployees;
The advantages of view :
When creating a multi table query statement , It's easy to have a lot of duplicate code , Creating views can effectively avoid duplicate code , It's very convenient to use .
1. The query name contains a The employee name of the character 、 Department name and job information
① establish
CREATE VIEW myv1
AS
SELECT last_name,department_name,job_title
FROM employees e
JOIN departments d ON e.department_id = d.department_id
JOIN jobs j ON j.job_id = e.job_id;
② Use
SELECT * FROM myv1 WHERE last_name LIKE '%a%';
Two 、 View modification
create or replace view View name
as
Query statement ;
3、 ... and 、 Delete view
grammar :drop view View name , View name ,…;
DROP VIEW emp_v1,emp_v2,myv3;
Four 、 View view
DESC myv3;
SHOW CREATE VIEW myv3;
5、 ... and 、 Update of view
CREATE OR REPLACE VIEW myv1
AS
SELECT last_name,email,salary*12*(1+IFNULL(commission_pct,0)) "annual salary"
FROM employees;
CREATE OR REPLACE VIEW myv1
AS
SELECT last_name,email
FROM employees;
1. Insert
INSERT INTO myv1 VALUES(' Xiaohong ','[email protected].com')
2. modify
UPDATE myv1 SET last_name = ' Xiao Ming ' WHERE last_name=' Xiaohong ';
3. Delete
DELETE FROM myv1 WHERE last_name = ' Xiao Ming ';
The view should try not to modify the data in the table, because it changes the data of several tables , So don't change it. It's usually used for querying and omitting duplicate code
边栏推荐
- 7.依赖注入
- 0x80131500 solution for not opening Microsoft Store
- Register service instances in ngmodule through dependency injection
- unity 最好用热更方案卧龙 wolong
- [fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
- 3D semantic segmentation - PVD
- 2w字详解数据湖:概念、特征、架构与案例
- 基于SqlSugar的开发框架循序渐进介绍(13)-- 基于ElementPlus的上传组件进行封装,便于项目使用
- 【redis】redis安装
- Baidu rich text editor ueeditor image width 100% adaptive, mobile terminal
猜你喜欢

2D semantic segmentation -- deeplabv3plus reproduction

MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具

Birui data joins Alibaba cloud polardb open source database community

2W word detailed data Lake: concept, characteristics, architecture and cases

吴恩达逻辑回归2
![[zeloengine] summary of pit filling of reflection system](/img/7a/c85ba66c5dd05908b2d784fab306a2.png)
[zeloengine] summary of pit filling of reflection system

QT ListView 列表显示组件笔记

QT listview list display component notes

Win11桌面切换快捷键是什么?Win11快速切换桌面的方法

激荡20年,芯片产能从零起步到反超美国,中国制造的又一大成就
随机推荐
【读书会第13期】+FFmpeg开源项目
MySQL implicit lock
Pagehelper.startpage is not effective
Test framework unittest command line operation and assertion method
伦敦银K线图的各种有用形态
Win11动态磁贴没了?Win11中恢复动态磁贴的方法
01.一个更简单的方法来传递大量的props
Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again
只有1000元能买什么理财产品赚钱?
百度富文本编辑器UEditor单张图片上传跨域
链游开发现成版 链游系统开发详细原理 链游源码交付
邮件的收发的展现逻辑之收件箱发件箱以及回复断链的问题
Sum arrays with recursion
Attachment handling of SAP Fiori
Recursive menu query (recursion: check yourself)
Slf4j and log4j2 process logs
【云驻共创】探秘GaussDB如何助力工商银行打造金融核心数据
[book club issue 13] +ffmpeg open source project
Intention lock
一文理解分布式开发中的服务治理