当前位置:网站首页>Addition, deletion, modification and query of the database at the terminal
Addition, deletion, modification and query of the database at the terminal
2022-07-27 06:26:00 【Envy only mandarin ducks, not immortals】
Catalog
One 、 Add, delete, modify and check the data table
(2) Single row full column insert
(4) Multi row full column insert
(1) Full row and full column search
(2) Finds the specified column
(7) Conditions of the query where sentence
(2) Modify one row and multiple columns
(4) Modify the data of the whole bank
One 、 Add, delete, modify and check the data table
1、 The new data
insert into Table name ( The attribute name )values( Property value );
(1) Insert one line

(2) Single row full column insert
No column name is specified after the table name when inserting ,, By default, full line insertion is required
insert into Table name values( Property value );

At this time, the data table has three columns , If values If the following value is followed by two attribute values, an error will be reported
If there is no data, use null placeholder


(3) Several rows and columns
insert into Table name ( Attribute types 1, Attribute types 2) values
( Property value 1, Property value 1),
( Property value 2, Property value 2),
( Property value 3, Property value 3);

(4) Multi row full column insert
insert into Table name values
( Property value 1, Property value 1),
( Property value 2, Property value 2),
( Property value 3, Property value 3);

2、 Query data

(1) Full row and full column search
select * from Table name ;
(2) Finds the specified column
select Column name , Column name from Table name ;

The query field is an expression
Check all student names , Chinese achievement +10 Result
It will not produce real +10 influence

Query student name and total score

(3) Alias query results
select Name as New name from Table name ;
(4) Go to check again
select diatint Column name from Table name ;
When multiple lines are de duplicated, the content of the whole line must be the same before it can be recognized as repetition

(5) Sort by results
select Column name from Table name
order by Column name [asc|desc];
among asc It's in ascending order , And the default sort is also ascending ,desc It's in descending order

If there is... In the data sheet 0 and null Time comparison ,Null The smallest , And smaller than a negative number

(6) Paging query
The query results are in accordance with the previous n Line output
select The attribute name from Table name limit n;
for example : Check the names of the top three students and the total score

The query results are in accordance with the previous n Line output , From s OK, let's start
select The attribute name from Table name limit n offset s; among s Similar to index
for example : The total query score is 3-6 My classmate

When n When it is greater than the actual number of rows , All rows will be displayed
When offset When it is greater than the actual number of rows, it will return null
(7) Conditions of the query where sentence


stay where Alias is not supported in statement ,order by Is in select Sort after the query results come out , and where The statement is filtered first and then executed select Of the query , In execution where When the sentence is ,select The alias of the statement has not yet started to execute , So alias cannot be used here
The total query score is greater than 200 Names of students and total scores

The total query score is less than 200 Classmate
You can see it Null Is not included in less than

Filter all students whose grades are not empty

You can see it ,null+ Any data is null,null Itself is not the actual value
(8) Interval query
between...and...;

and

(9) Contains the query
in

(10) Fuzzy query
like
Check the names of all students with small letters in their names

“”_“” Match exactly one character
Query all names, the name has three words and the small word is in the second position

3、 Modify table data
upate Table name se Name = Modified expression

(1) Modify one line
for example : Will Li Si's English +20 branch
(2) Modify one row and multiple columns
for example : take · Zhu Bajie's Chinese and math scores add 10 branch

(3) Modify multiline data
for example : The math scores of all students with small characters in their names in the grades will be reduced 10 branch
Be careful : When the modified attribute value exists null when , Cannot be modified
(4) Modify the data of the whole bank
When the command is not followed by where When filtering, it is the whole line modification
for example : Reset all students' English grades to 0

4、 Delete data
delete from Table name where Filter conditions
(1) Delete a data
for example : Delete the record of Zhang San
(2) Delete the whole table
No addition where filter ,delete Full table deletion is a row by row execution delete Delete operation , The number of affected rows will be displayed , The table is still after deletion , But all the data is not for ,delete Delete slowly , Data can be recovered , You can add where Filter conditions

truncate table Table name ;
truncate Delete clears the data in all tables , The number of affected rows is not displayed , It is equivalent to directly adjusting the file size to 0, But the table is still there after deletion ,truncate Delete fast , Data is not recoverable , No conditions

drop table Table name ;
drop Delete is to delete the table directly , It is equivalent to deleting the file of the table directly , Irrecoverable , Delete the fastest
边栏推荐
猜你喜欢

Automated Deployment Project

Ulcl function --5gc

Linear progression for face recognition

二叉树——搜索树

多线程常见锁的策略

Pzk learns data types, binary conversion, input and output, operators, branch statements, ifelse of C language

正则表达式

Unable to start program, access denied?

允许或者禁止同时连接到一个non-domain和一个domain网络

UnityShader-LowPoly
随机推荐
软件测试用里篇
单元集成(接⼝)测试
Knowledge supplement of multithreading
Programming learning records - Lesson 6 [functions]
Communication mechanism cases
通信机制案例
Compatibility test knowledge points
TF坐标变换
5G的前世今生---简述移动通信的发展
C language - file operation
Programming learning records - Lesson 9 [operators]
What is the difference between single line and three line when renting servers in Hong Kong?
Three ways to get RPM packages using yum
Related knowledge of internal classes
测试基础概括
Multi threaded CAS, synchronized lock principle, JUC and deadlock
jmeter简介
数据库的索引和事务(重点)
Wireshark function introduction
iptables防火墙及SNAT和DNAT