当前位置:网站首页>First knowledge database
First knowledge database
2022-07-06 05:40:00 【ythswzgxlp】
Command operation :
Access to database :mysql -h Host name -P Port number -u user name -p password ( I don't mean to write everything , But to avoid mistakes, it's best to write , It is generally recommended to enter the next line of the password to ensure security )
view the database :show databases Database name ;
See the table :show table Table name ;
Using a database :use Database name ;
DQL:
The execution order of query statements and the keywords included in a query statement :

Connection type classification : Internal connection (inner join), External connection , Cross connect
Inner connection classification : Equivalent connection , Non equivalent connection , Self join
External connection classification : The left outer join (left outer), Right connection (right outer), Full outer join
The left outer join ,left join The main table on the left ; Right connection ,right join The main table on the right
The difference between internal and external connections : Inner join is the intersection of two tables ; The external connection is the main table plus the connection part
DDL:
establish :create modify :alter Delete :drop
Library management :
establish :create database 【if not exists( Determine whether the database already exists )】 Library name ;
modify ( Generally, it is the modification of character set ):alter database Library name character set Character set format ;
Delete :drop database 【if exists( Determine whether the database already exists )】 Library name ;
The management of the table :
establish :create table 【if not exists】 Table name ( Name The type of the column 【( length ) constraint ( Optional )】,( Name The type of the column 【( length ) constraint ( Optional )】,... ,( Name The type of the column 【( length ) constraint ( Optional )】)
modify :alter table Table name add | drop | modify | change column Name 【 Name Column type constraint 】
Delete :drop table 【if exists】 Table name ;
Copy :
Just copy the structure of the table , The contents in the table will not be copied :create table Table name to copy like The name of the copied table
Copy table structure and data :create table New table select * from The name of the copied table
Copy only part of the data :create table New table select ...( Filter conditions and columns to be copied ) from The name of the copied table
Just copy the structure of some fields :create table New table select ... where 0( Use 0 Express false, No data )
DML:
Insert :insert into Table name set Name 1= value 1, Name 2= value 2,........;
modify :update Table name set Column 1= value 1, Column 2= value 2,.... where filter ;
Delete : Method 1 :truncate table Table name ;
Method 2 :delete from Table name where filter
Common constraints :
classification ( Six constraints ):
not null: Non empty constraint , Used to ensure that the field cannot be empty
default The default value is : Default , Used to ensure that the field has a default value
primary key: Used to ensure that the value of this field is unique , And not empty
unioue: only , Used to ensure that the value of this field is unique , Can be null
check( Inspection conditions ): Check constraint (mysql China does not support it. , But no mistake , It just didn't work )
foreign key ( Column name from table )references Main table name ( Name of main table ): The associated column of the main table must be a unique column ( It's usually a primary key or unique , It can also be a foreign key , But there is repetition and it is not recommended )
Three paradigms of database :
First normal form : First normal form (1NF): Attributes are inseparable , That is, each attribute is an indivisible atomic item . It is not allowed that attributes can be further divided
Second normal form : Second normal form (2NF): Satisfy the first paradigm ; And there are no partial dependencies , That is, the non primary attribute must be completely dependent on the primary attribute . example : There are dependencies between primary keys and non primary keys . But there is no dependency between non primary keys
Third normal form : Third normal form (3NF): Satisfying the second paradigm ; And there is no transitive dependency , That is, non primary attributes cannot have dependencies with non primary attributes , Non primary attributes must be directly dependent on primary attributes , You can't depend on the primary property indirectly .
Non primary keys must directly depend on primary keys , Non primary keys cannot indirectly depend on primary keys
Isolation level classification :
read uncommitted: Dirty reading will occur , It can't be read repeatedly , Fantasy reading
read committed: Avoid dirty reading , There will be non repeatable reading , Fantasy reading
repeatable read: Avoid dirty reading , It can't be read repeatedly , Fantasy reading
serializable: Avoid dirty reading , It can't be read repeatedly , Fantasy reading , But the performance is low
The transaction ACID attribute :
1. Atomicity (Atomicity): Atomicity means that a transaction is an indivisible unit of work , Either the operations in the transaction occur , Or none at all .
2. Uniformity (Consistency): Transactions must transform data from one consistency state to another .
3. Isolation, (Isolation): Transaction isolation means that the execution of one transaction cannot be interfered by other transactions , That is, the operations and data used within a transaction are isolated from other concurrent transactions , Transactions that execute concurrently cannot interfere with each other .
4. persistence (Durability): Persistence means that once a transaction is committed , Its changes to database data are permanent , Other subsequent operations and database failures should not have any impact on it .
边栏推荐
- Cuda11.1 online installation
- P2802 回家
- [experience] install Visio on win11
- js Array 列表 实战使用总结
- 无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
- How can large websites choose better virtual machine service providers?
- 05. 博客项目之安全
- Vulhub vulnerability recurrence 67_ Supervisor
- Game push: image / table /cv/nlp, multi-threaded start!
- Graduation design game mall
猜你喜欢

Pix2pix: image to image conversion using conditional countermeasure networks

RustDesk 搭建一个自己的远程桌面中继服务器

Summary of deep learning tuning tricks
[SQL Server Express Way] - authentification et création et gestion de comptes utilisateurs

How to use PHP string query function
![[cloud native] 3.1 kubernetes platform installation kubespher](/img/86/137a65a5b58bc32e596d2a330ca9fc.png)
[cloud native] 3.1 kubernetes platform installation kubespher

01. Project introduction of blog development project

js Array 列表 实战使用总结

Graduation design game mall

Codeforces Round #804 (Div. 2) Editorial(A-B)
随机推荐
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Pointer classic written test questions
无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
UCF(2022暑期团队赛一)
Solution of QT TCP packet sticking
应用安全系列之三十七:日志注入
Jushan database appears again in the gold fair to jointly build a new era of digital economy
Huawei od computer test question 2
HAC集群修改管理员用户密码
【SQL server速成之路】——身份验证及建立和管理用户账户
MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[experience] install Visio on win11
02. Develop data storage of blog project
指針經典筆試題
Figure database ongdb release v-1.0.3
[SQL Server fast track] - authentication and establishment and management of user accounts
Promotion hung up! The leader said it wasn't my poor skills
Unity gets the width and height of Sprite