当前位置:网站首页>Knowledge of dark horse database
Knowledge of dark horse database
2022-07-16 06:58:00 【Springxing star】
Table relations
one-on-one , Realization way : Add foreign keys on either side , Associate another party's primary key , And set the foreign key to be unique (unique)
One to many , Add more foreign keys , Associated primary key
Many to many , Realization way : Create a third intermediate table , The middle table contains at least two foreign keys , Associate the primary keys of two parties respectively
Multi-table query :
The cartesian product : take A,B Set all combinations
Multi-table query : Query data from multiple tables
① Link query
Internal connection : It is equivalent to a query A,B Intersection data
External connection :① The left outer join : It is equivalent to a query A Table all data and intersection part data
② Right connection : It is equivalent to a query B Table all data and intersection part data
② Subquery
Inner join query syntax
① Implicit inner join
select Field list from surface 1, surface 2... where Conditions ;
② Display inner connection
select Field list from surface 1 [inner] join surface 2 on Conditions
example :select * from emp inner join dept on emp.dep_id = dept.did;
1. The left outer join : It is equivalent to a query A All the data + The intersection part
select Field list from surface 1 left [outer] join surface 2 on Conditions ;
example :select * from emp left join dept on emp.dep_id = dept.did;
2. Right connection : It is equivalent to a query B All the data + The intersection part
select Field list from surface 1 right [outer] join surface 2 on Conditions ;
Subquery ( nested queries )
1. Sub query concept : Nested query in query , A nested query is called a subquery
2. Sub queries differ according to the query results , The effect is different , It is divided into :
① Single row single row : As a condition value , Use =,!=,>,< Wait for conditional judgment
select Field list from surface where Field name =( Subquery )
② Multi row single row : As a condition value , Use in And other keywords for conditional judgment
select Field list from surface where Field name in ( Subquery )
③ Multiple rows and columns : As a virtual table
select Field list from ( Subquery ) where Conditions
Business profile :
① Database transactions (transaction) It's a mechanism , A sequence of operations , Contains a set of database operation commands
② The transaction submits or revokes the operation request to the system as a whole , That is, this set of database commands either succeed at the same time , Or fail at the same time .
③ A transaction is an indivisible unit of work logic
--- Open transaction
begin or start transaction;
--- Commit transaction ( The data is temporary , Submitted is permanent , You can access )
commit;
--- Roll back the transaction ( Rollback to before starting the transaction )
rollback;
The interview asked :
Four characteristics of business (ACID)
① Atomicity (Atomicity): Transactions are the smallest and indivisible unit of operation , Or at the same time , Or fail at the same time
② Uniformity (consistency): When the transaction completes , All data must be kept consistent
③ Isolation, (isolation): Between multiple transactions , Visibility of actions
④ persistence (durability): Once a transaction is committed or rolled back , Its changes to the data in the database are permanent
MySQL Transactions are automatically committed by default (oracal To submit manually )
--- View the default commit method for transactions
select @@autocommit;
The result is 1 Automatic submission 0 Manual submission
--- Modify the transaction submission method
set @@autocommit = 0;
边栏推荐
- Pat's notes on question brushing [collation of English expressions of unknown key points in the title]
- KMP中的最小循环节
- [hbuilderx development uniapp] automatic code formatting plug-in installation and configuration
- [introduction to go language] 03 go language data types, variables, constants
- [Go语言入门] 04 Go语言运算符
- PAT刷题笔记之【题目中出现的不认识的重点英文表达整理】
- CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
- Vectorization of gradient descent method
- go语言json解析库jsoniter的使用(替换标准库encoding/json)
- DL第七天
猜你喜欢
随机推荐
01kNN_ Regression
[Go语言入门] 12 Go语言结构体(struct)详解
[C language] college student attendance management system
[Go语言入门] 11 Go语言函数
动态开点线段树
SSM图书管理系统
交易模块开发
RT_ Thread critical zone protection
001 空指针和野指针
vim用法
3.6 formatting numbers and strings
数组扁平化实现
DL第五天
LeetCode 刷题 第七天
Three minute markdown -- a quick start to basic grammar
四舍五入,向下取整,向上取整的使用
Excel-1
支付宝电脑网站支付
js制作动态小火箭
数据库黑马笔记DML






![[cloud native | middleware] open source SPL can easily cope with t+0](/img/52/85fde54c79b6b955964c05d28dbfbb.png)


