当前位置:网站首页>Database base (Study & review for self use)
Database base (Study & review for self use)
2022-06-30 05:04:00 【A Niu Niu Niu Niu Niu】
Let's start with a brain map :
One : The four operations of database ( Add or delete check change )
1: Library operation
1: Create database
sentence :create database Library name ( You can add character set settings :character set utf8)
2: view the database
sentence :show databases
3: Delete database
sentence : drop database Library name
4: Change database
sentence : alter database Library name + Operation of the library
5: Using a database
sentence : use Library name
2: Table operations
1: Create table
sentence :create table Table name ( You can add character set settings :character set utf8)
2: See the table
sentence :show table
3: Delete table
sentence : drop table Table name
4: Change table
sentence : alter table Table name + Operation of the watch
3: Data manipulation
1: insert data ( increase )
sentence :insert into Table name ( Field ) values( value )
2: Delete data
sentence :delete from Table name where Conditions
3: Modifying data
sentence : update Table name set Field = value where Conditions
4: Query data
sentence : select Field from Table name where Conditions
Two : Table joins
1: Internal connection
key word :inner join
grammar : select Field from surface 1 inner join surface 2 where Conditions
2: The left outer join
key word :left join
grammar : select Field from Main table left join From the table where Conditions
3: Right connection
key word :right join
grammar : select Field from From the table right join Main table where Conditions
4: Subquery
No keyword
grammar :select Field from Parent table where Field Operator (select Field from Sub table where Conditions )
exists Subquery : The return value is of boolean type
grammar :select Field from Parent table where exists (select Field from Sub table where Conditions )
If returns true, Outer query execution ; if false, The outer query does not execute
notes : The return value of subquery cannot be more than 1 individual
Subqueries can be used properly instead of table joins
3、 ... and : Add
1: Fuzzy query
key word :like
Key characters :
[ ]: contain
^: Remove
%: Any character of any length
_: Any character
example :select name from student where name like ‘ Zhang %’;
That is to query the name of the student surnamed Zhang in the student table
2: Remove duplicate data
key word :distinct
example :select distinct name from student ;
Look up the student's last name in the student table , Remove duplicate names
3: Sort
key word :order by
Ascending order :abs( By default, the system also arranges in ascending order )
Descending order :desc
example :select id,name fromstudent order by id asc( Omission );
Look up the student's name and number in the student table , And arrange them in ascending order
select id,name fromstudent order by id desc;
Look up the student's name and number in the student table , And arrange them in descending order
notes : If you want to sort by the phonetic alphabet of names , You need to modify the character set when querying
example :select id,name from student order by convert (name using gbk);
Look up the student's name and number in the student table , And arrange them in ascending order according to the phonetic alphabet of the names
4: Limit
key word :limit Limit the number of pieces of data queried
example : select id,name from student limit 0 ,5;
Query the data of the first five items in the student table
5: Aggregate functions
1:avg() averaging
2:count() Find the total
3:max() For maximum
4:min() For the minimum
5:sum() Sum up notes : Aggregate functions must be used with grouped queries
6: grouping
key word :group by
Sentence order :
where > group by > having
select
...
from
...
where
...
group by
...
having
...
order by
...
7: Specify query
key word :in
Multiple pieces of data can be queried , As long as the conditions are met, you can query and return
example :select id,name from student where id in(4,5,6);
Query the student table id by 4,5,6, Number and name of the student
8: Logical operators
And :and
or :or
Not :not
~~ There is still a lot of knowledge about databases , This article only wants to use when reviewing , If there is any mistake or incompleteness , Also please indicate , Correction with an open mind , Thank you very much !
边栏推荐
- Connect() and disconnect() of socket in C #
- Winter vacation parent-child tour, these new york attractions are not only fun but also knowledge
- Detailed explanation of sorting sort method of JS array
- Chapter 9 of OpenGL super classic (version 7): fragment processing and frame buffering
- Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)
- Pycharm database tool
- Have a heart beating Valentine's day in Singapore
- Unity application class and data file path
- 2021-06-17 solve the problem of QML borderless window stretching, window jitter and flicker when stretching and shrinking
- 【VCS+Verdi聯合仿真】~ 以計數器為例
猜你喜欢
Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok
Sourcetree usage
Unity/ue reads OPC UA and OPC Da data (UE4)
Pit of smoothstep node in shadergraph
力扣349. 两个数组的交集
力扣977. 有序数组的平方
Autowired注解警告的解决办法
PWN入门(2)栈溢出基础
Connect() and disconnect() of socket in C #
MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
随机推荐
Create a simple battle game with photon pun
Photon pun refresh hall room list
Preorder traversal of Li Kou 589:n fork tree
Ripple effect of mouse click (unity & shader)
Unity download and installation website
Force buckle 349 Intersection of two arrays
redis集群概念
Webots notes day 2
Easyrecovery data recovery software recovers my photo and video data two years ago
003-JS-DOM-Attr-innerText
[recruitment] UE4 Development Engineer
Harbor API 2.0 query
Important knowledge points in unity3d
很紧张,第一天做软件测试,需要做什么?
Operation file file class method
C # three ways to obtain web page content
Unity3d realizes Google Digital Earth
Unreal 4 learning notes - Animated Montage
Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
Chapter 11 advanced data management of OpenGL super classic (version 7)