当前位置:网站首页>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
边栏推荐
猜你喜欢
MySQL transaction and isolation level
Shenji Bailian 3.53-kruskal
Ti millimeter wave radar learning (I)
ES6的详细注解
Comment utiliser mitmproxy
Detailed notes of ES6
神机百炼3.54-染色法判定二分图
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
DRM display framework as I understand it
【C语言】简单实现扫雷游戏
随机推荐
Linkage between esp8266 and stc8h8k single chip microcomputer - Weather Clock
TypeScript的泛型和泛型约束
数据回放伴侣Rviz+plotjuggler
Zabbix Server trapper 命令注入漏洞 (CVE-2017-2824)
Several keywords in C language
DRM display framework as I understand it
Picture clipping plug-in cropper js
vite如何兼容低版本浏览器
ROS2----LifecycleNode生命周期节点总结
Redis key value database [primary]
Test case
PHP read file (read JSON file, convert to array)
STC8H8K系列汇编和C51实战——按键允许按键计数(利用下降沿中断控制)
[C language] screening method for prime numbers
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
Some descriptions of Mipi protocol of LCD
页面打印插件print.js
TI毫米波雷达学习(一)
CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
神机百炼3.52-Prim