当前位置:网站首页>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 .
边栏推荐
- Jvxetable用slot植入j-popup
- Steady, 35K, byte business data analysis post
- JS array list actual use summary
- UCF (summer team competition II)
- 大型网站如何选择比较好的云主机服务商?
- 什么是独立IP,独立IP主机怎么样?
- Problems encountered in installing mysql8 on MAC
- 移植InfoNES到STM32
- [SQL Server fast track] - authentication and establishment and management of user accounts
- 初识数据库
猜你喜欢
清除浮动的方式
Text classification still stays at Bert? The dual contrast learning framework is too strong
First acquaintance with CDN
Configuration file converted from Excel to Lua
Zoom and pan image in Photoshop 2022
SequoiaDB湖仓一体分布式数据库2022.6月刊
Graduation design game mall
B站刘二大人-数据集及数据加载 Lecture 8
What preparations should be made for website server migration?
Pointer classic written test questions
随机推荐
Pytorch代码注意的细节,容易敲错的地方
无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
What is independent IP and how about independent IP host?
[experience] install Visio on win11
P2802 回家
MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
剑指 Offer II 039. 直方图最大矩形面积
【云原生】3.1 Kubernetes平台安装KubeSpher
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
Quantitative description of ANC noise reduction
Figure database ongdb release v-1.0.3
B站刘二大人-多元逻辑回归 Lecture 7
Summary of deep learning tuning tricks
初识CDN
Promise summary
01. Project introduction of blog development project
Jushan database appears again in the gold fair to jointly build a new era of digital economy
[Tang Laoshi] C -- encapsulation: classes and objects
PDK工藝庫安裝-CSMC
注释、接续、转义等符号