当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Redis message queue
RustDesk 搭建一个自己的远程桌面中继服务器
Easy to understand IIC protocol explanation
Codeforces Round #804 (Div. 2) Editorial(A-B)
04. 项目博客之日志
[SQL Server Express Way] - authentification et création et gestion de comptes utilisateurs
[JVM] [Chapter 17] [garbage collector]
Remember an error in MySQL: the user specified as a definer ('mysql.infoschema '@' localhost ') does not exist
Rustdesk builds its own remote desktop relay server
Vulhub vulnerability recurrence 69_ Tiki Wiki
随机推荐
PDK process library installation -csmc
Improve jpopup to realize dynamic control disable
Vulhub vulnerability recurrence 69_ Tiki Wiki
02. Develop data storage of blog project
Game push image / table /cv/nlp, multi-threaded start
UCF(2022暑期团队赛一)
Steady, 35K, byte business data analysis post
【经验】win11上安装visio
毕业设计游戏商城
嵌入式面试题(一:进程与线程)
01. 开发博客项目之项目介绍
How to download GB files from Google cloud hard disk
B站刘二大人-多元逻辑回归 Lecture 7
网站进行服务器迁移前应做好哪些准备?
备忘一下jvxetable的各种数据集获取方法
算法-- 爬楼梯(Kotlin)
Redis消息队列
Installation de la Bibliothèque de processus PDK - csmc
01. Project introduction of blog development project
Sequoiadb Lake warehouse integrated distributed database, June 2022 issue