当前位置:网站首页>View of MySQL introductory learning (III)
View of MySQL introductory learning (III)
2022-06-23 05:23:00 【The silent Lord returns to the sand】
- View
Concept : A virtual table extracted from one or more tables , To manipulate virtual tables CRUD Exactly the same as the original table
advantage :
1. simple , After extracting from multiple tables , Just manage the virtual tables
2. Security , All you can see is the fields extracted from the virtual table
3. Logical independence
shortcoming :
1. There's no performance improvement , Simple tables can become complex
2. It's inconvenient to modify , In many cases, you cannot modify the virtual table
Create view :
create view myView as
select employee_id,first_name,last_name,salary from t_employees;
select * from myView;
update myView set salary=30000 where employee_id=100;
Modify the view :
The way 1: Create or modify
CREATE OR REPLACE VIEW myView AS
select employee_id,first_name,last_name from t_employees;
The way 2: Modify the view
alter VIEW myView AS
select employee_id,first_name,last_name,salary from t_employees;
Delete view
drop view myView;
View immutability :
create view myView as
select department_id,count(*) from t_employees group by department_id;
update myView set department_id=119 where department_id=10;
2. Comprehensive practice
Import data first , Then complete the following exercise :
1. Query orders of all users
select * from user u inner JOIN orders o on u.userid=o.userid;
2. Query the user id by 1 All order details for
select * from user u INNER JOIN orders o on u.userid=o.userid
INNER JOIN orderitem oi on o.oid= oi.oid where u.userid=1;
3. View the order of Zhang San
select * from orders where userid=(select userid from user where username=' Zhang San ');
4. The price of the queried order is greater than 800 All user information for .
select * from user where userid in (select DISTINCT userid from orders where totalprice>800);
5. Query all order information , Each page shows 5 Data
select * from orders limit 0,5; first page
select * from orders limit 5,5; The second page
select * from orders limit 10,5; The third page
law :
The current page is known , Page size ( Number of entries per page ), Find starting subscript
Start subscript = ( The current page -1)* Page size
边栏推荐
- MCS:连续随机变量——Chi-Square分布
- 大環境不好難找工作?三面阿裏,幸好做足了准備,已拿offer
- Difficult to find a job in a bad environment? Ali on three sides. Fortunately, he has made full preparations and has offered
- 导出带水印的PDF
- STP summary
- 同步国内AOSP代码相关错误
- H5 adaptive full screen
- Visual display of TEQC quality analysis results using teqcplot
- Drag and drop拖放框架
- C language stack implementation
猜你喜欢

【微服务|Nacos】Nacos版本相关问题一览

8 years' experience: monthly salary of 3000 to 30000, the change of Test Engineer

搭建一套 gocd 的环境

Memory model of JVM principle

A bug in rtklib2.4.3 B34 single point positioning

Image noise reduction denoise AI

(IntelliJ)插件一 Background Image Plus

计算欧式距离和余弦相似度

网上有真实的兼职吗?大学生怎么找暑期兼职?

618 how to break through the siege? Haier Zhijia: do a good job in digitalization of users
随机推荐
渗透测试基础 | 附带测试点、测试场景
bat中获取bat命令结果
Mysql入门学习(一)之语法
大环境不好难找工作?三面阿里,幸好做足了准备,已拿offer
Konva series tutorial 1:what is konva?
ES6的Array.from方法创建长度为N的undefined数组
MCS: continuous random variable lognormal distribution
CF【1700D】D. River Locks(dp、二分、数学)
Strong push, quick start to software testing
如何进行探索性数据分析
UI automation positioning edge -xpath actual combat
How to conduct exploratory data analysis
(IntelliJ)插件一 Background Image Plus
C语言栈实现
弱者易怒如虎,强者平静如水,真正厉害的人早已戒掉了情绪
UnityShader入门精要——Unity中的渲染优化技术(四)
Fund performance evaluation
Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan
组合式API-composition-api
关于重放攻击和防御