当前位置:网站首页>Database learning summary 5
Database learning summary 5
2022-07-02 06:01:00 【Eyes are still playing hide and seek 81】
One 、 Multi-table query
1. grammar :
select
List of names
from
List of table names
where...
The cartesian product : Yes A,B Two sets , All the components of these two sets ;
To complete a multi table query , Need to eliminate useless data
2. Classification of multi table query
(1) Internal connection query
First, make sure :
Query data from those tables
What are the conditions
Which fields to query
a. Implicit inner join : Use where Condition clear useless data
select Field list from List of table names where Table name 1.` Name ` = Table name 2.` Name `;
The name fields of two tables may be repeated , You can use table name punctuation before column name to distinguish ;
But it's going to be a lot of trouble , You can alias a table
select
t1.name,
t1.age,
t2.name
from
Table name 1 t1,
Table name 2 t2
where
t1.` Name ` = t2.` Name `;
Each field has only one line, so it is convenient to add comments after it
b. Explicit inner connection :
select Field list from Table name 1 【inner】 join Table name 2 on Conditions ;
【inner It can be omitted 】
(2) External connection query
a. The left outer join : It queries all the data in the left table and its intersection part
select Field list from Table name 1 left 【outer】 join Table name 2 on Conditions ;
【outer It can be omitted 】
b. Right connection : It queries all the data in the left table and its intersection part
select Field list from Table name 1 right 【outer】 join Table name 2 on Conditions ;
【outer It can be omitted 】
(3) Subquery : Nested query in query
a. The result of subquery is single row and single column :
Subqueries can be used as conditions , Use operators to judge (>、<、>=、<= Isomorphic operator )
b. The result of subquery is multi row and single column :
Subqueries can be used as conditions , Use operators to judge ( in And so on )
c. The result of subquery is multi row and multi column :
A subquery can be used as a Virtual table
Two 、 Business
1. Basic introduction to the business
(1) Concept : If a business operation contains multiple steps , Managed by affairs , So these operations are either successful at the same time , Or fail at the same time .
(2) operation
a. Open transaction :start transaction;
b. Roll back :rollback;
c. Submit :commit;
(3) Two ways to commit a transaction
a. Automatic submission :mysql It's automatic submission , One DML( Additions and deletions ) Statement will be automatically submitted once
b. Manual submission : You need to start the transaction before committing
(4) Modify the default submission method
a. View the default submission method :SELECT @@autocommit; -- 1 On behalf of auto submit -- 0 On behalf of hand submit
b. Modify the default submission method :SET @@autocommit = 0;
2. The four characteristics of affairs
(1) Atomicity : Is an indivisible minimum operating unit , Or at the same time , Or fail at the same time .
(2) persistence : When a transaction is committed or rolled back , The database will persist the data .
(3) Isolation, : Between many things , Are independent of each other .
(4) Uniformity : Before and after transaction operation , The total amount of data remains the same .
3. The isolation level of the transaction ( understand )
(1) Concept : Isolated... Between multiple transactions , Mutually independent . But if multiple transactions operate on the same batch of data at the same time , It will cause some problems , Setting different isolation levels can solve these problems
边栏推荐
- Redis key value database [seckill]
- Software testing - concept
- Addchild() and addattribute() functions in PHP
- 神机百炼3.52-Prim
- MUI底部导航的样式修改
- 【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
- MySQL transaction and isolation level
- Detailed notes of ES6
- 15 C language advanced dynamic memory management
- 测试 - 用例篇
猜你喜欢
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
VSCode paste image插件保存图片路径设置
[C language] simple implementation of mine sweeping game
Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
memcached安装
DRM display framework as I understand it
Ti millimeter wave radar learning (I)
"Simple" infinite magic cube
经典文献阅读之--SuMa++
我所理解的DRM显示框架
随机推荐
How to use mitmproxy
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
Comment utiliser mitmproxy
Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)
Shenji Bailian 3.54-dichotomy of dyeing judgment
死磕大屏UI,FineReport开发日记
经典文献阅读之--Deformable DETR
Cookie plugin and localforce offline storage plugin
Can't the dist packaged by vite be opened directly in the browser
STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
Go 学习笔记整合
ROS2----LifecycleNode生命周期节点总结
Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
PHP read file (read the specified line containing a string in the file)
Common websites for Postgraduates in data mining
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
Mock simulate the background return data with mockjs
如何使用MITMPROXy
PHP parent