当前位置:网站首页>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 .
边栏推荐
- 05. Security of blog project
- C进阶-数据的存储(上)
- 02. Develop data storage of blog project
- Installation de la Bibliothèque de processus PDK - csmc
- Migrate Infones to stm32
- Analysis of grammar elements in turtle Library
- 03. 开发博客项目之登录
- Promotion hung up! The leader said it wasn't my poor skills
- MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
- Promotion hung up! The leader said it wasn't my poor skills
猜你喜欢

Redis消息队列

Figure database ongdb release v-1.0.3

注释、接续、转义等符号
[email protected]树莓派"/>[email protected]树莓派

Summary of deep learning tuning tricks

What preparations should be made for website server migration?

Remember an error in MySQL: the user specified as a definer ('mysql.infoschema '@' localhost ') does not exist

P2802 回家

Graduation design game mall

Vulhub vulnerability recurrence 69_ Tiki Wiki
随机推荐
What impact will frequent job hopping have on your career?
Web Security (VI) the use of session and the difference between session and cookie
What is independent IP and how about independent IP host?
05. Security of blog project
Redis message queue
毕业设计游戏商城
指针经典笔试题
Easy to understand IIC protocol explanation
应用安全系列之三十七:日志注入
算法-- 爬楼梯(Kotlin)
【SQL server速成之路】——身份驗證及建立和管理用戶賬戶
Promotion hung up! The leader said it wasn't my poor skills
28io stream, byte output stream writes multiple bytes
[QNX Hypervisor 2.2用户手册]6.3.3 使用共享内存(shmem)虚拟设备
B站刘二大人-数据集及数据加载 Lecture 8
P2802 回家
Check the useful photo lossless magnification software on Apple computer
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
Algorithm -- climbing stairs (kotlin)
How to get list length