当前位置:网站首页>MySQL tutorial: MySQL database learning classic (from getting started to mastering)
MySQL tutorial: MySQL database learning classic (from getting started to mastering)
2022-07-26 02:44:00 【Code Xiaoyi】
All systems in the field of software engineering , We should start with these two questions
1“ What is it? ?“
2“ Why have this ?
What is a database ?
database , Used to store data . It's made up of tables , There can be 0 To n A watch ,
It's like a watch Excel, It's suitable for storing some simple text messages ——
A person's ID number
Phone number
full name
Excel What information is not suitable for storage ?
Photo
The movie
A novel
These single large file objects , Not in the database .
for instance , All the goods on Taobao , The commodity information behind it 、 Store information 、 Sales and other data , Lying in a table in the database , But the promotional video on the store 、 picture 、 music , Not in the database .
There are all kinds of databases in the world , But fortunately , You just need to learn MySQL Basic usage , You can deal with most scenarios .
MySQL What is it? ?
MySQL It's a database software , Database and MySQL The relationship between , It's like chat software and QQ、 Wechat relationship .
There are all kinds of databases in the world , such as Oracle、MySQL、SQL Server wait , Most Internet companies use MySQL, Because it's free 、 The most widely used .
General interview , I will only ask MySQL Relevant knowledge .
SQL What is it? ?
Is a programming language , It's like Java、C++、Python, But it's very simple .
SQL It's a language for manipulating databases .
Just a hundred English words ,SQL You can do dazzling operations on the data , Very easy to get started .
To sum up , A database is a data storage system , The most representative of them is MySQL, It's the most widely used database , We use SQL Language operates on him .
The second question is ——
Why have databases ?
because Excel Not for a large system , Its performance is not good enough . We need a place where multiple people can visit at the same time 、 manipulation 、 Secure data storage system .
Generally speaking , The database is a shared hard disk , Multiple people can visit at the same time 、 Change data . There's a lot of data (0~300G) When , The performance of the database will be very good .
( Imagine a few dozen G Of Excel, It's going to be very difficult to operate )
How to learn database ?
I'm not going to introduce the concept , Let's copy the code and run . Don't be surprised , The starting point for almost all programmers is to copy code , To run the .
Generally speaking , We need to download free MySQL Installation , But it's too expensive for ordinary people , You may encounter various installation errors , I strongly don't recommend wasting time on such things . Fortunately, there is a website , You can use it online
We will start from the following N Let's operate the database step by step .
1, Create a form . There's some data in there .
2, Query data .
3, Fancy query data .
First step , Create tables and insert data
The goal is : Build a simple table :
We open the website 
Put the following SQL sentence , Copy to the left border of the page :
Be careful , Don't copy and paste with the mouse , Use the keyboard to operate . Or you might throw it wrong .
If you keep throwing it wrong , Just copy the code to txt In file , And then paste it on the website .
CREATE TABLE `student_info` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id, Primary key ',
`student_name` varchar(50) COMMENT ' The student's name ',
`student_age` int COMMENT ' Student age ',
`student_sex` varchar(10) COMMENT ' Student gender ',
PRIMARY KEY (`id`)
);
INSERT INTO `student_info`
(`student_name`, `student_age`,`student_sex`)
VALUES
(' Ge Yao ', 17 , ' male ')
;
INSERT INTO `student_info`
(`student_name`, `student_age`,`student_sex`)
VALUES
('XH', 23 , ' male ')
;
INSERT INTO `student_info`
(`student_name`, `student_age`,`student_sex`)
VALUES
('QHR', 24 , ' male ')
;
INSERT INTO `student_info`
(`student_name`, `student_age`,`student_sex`)
VALUES
('WR', 22 , ' Woman ')
;
In the left input box , Copy the above SQL, Click on build Schema
This completes the creation of the table , And the operation of inserting data . I feel confused ? No problem , Let's look up the data .
The second step , Query data
Copy the following code to the input field on the right side of the page , Click on Run SQL
selectid
,student_name
,student_age
from student_info
;
#! Copy to the right side of the page , Click on Run SQL
With 4 It's data !
If you're tired of listing , You can also write
select
*
from `student_info`;
All columns are pulled out by default , as follows :
If you still feel confused , No matter what it means , Just know that we already have the following 4 Data

altogether 4 Bar record , Represents the 4 A student , Their names are on the list 、 Age 、 Gender .
The third step , Do some fancy queries
Some commonly used scenes , such as ——
List all the boys : Copy the following code to the right border , Click on Run SQL
select
*
from `student_info`
where `student_sex`=' male '
;

List all older than 20 Year old student
select
*
from `student_info`
where `student_age` > 20
;

List all older than 20 A 12-year-old schoolboy
select
*
from `student_info`
where `student_age` > 20
and `student_sex` = ' male '
;

List all the boys , In ascending order of age (1,2,3…)
select
*
from `student_info`
where `student_sex` = ' male '
order by `student_age` ASC
;

Sort the boys by age , List the youngest 2 personal :
select
*
from `student_info`
where `student_sex` = ' male '
order by `student_age` ASC
limit 2
;

The last common keyword ,group by
Group the students by gender , Find out the biggest age difference between men and women
This requirement , actually , It's about taking data out of the table first , And then it's divided by gender 2 Group , And then in each group , Find the oldest number .
select
`student_sex`
, max( `student_age` )
from `student_info`
group by `student_sex`
;

This is a complicated operation , We can talk about it later .
Finally, thank everyone who reads my article carefully , The following online link is also a very comprehensive one that I spent a few days sorting out , I hope it can also help you in need !
These materials , For those who want to change careers 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful ……
If you don't want to grow up alone , Unable to find the information of the system , The problem is not helped , If you insist on giving up after a few days , You can click the small card below to join our group , We can discuss and exchange , There will be various software testing materials and technical exchanges .
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
Self study recommendation B Stop video :
Zero basis transition software testing : Self taught software testing , Got the byte test post offer, Is the B The best video station !
Advanced automation testing : Huawei has landed , Salary increase 20K,2022 Most suitable for self-study python Automated test tutorial , Spend it yourself 16800 Bought , Free sharing

边栏推荐
- EAM系统能帮助企业做什么?
- scipy.sparse.vstack
- Bo Yun container cloud and Devops platform won the trusted cloud "technology best practice Award"
- 图像识别(六)| 激活函数
- From a data incremental processing problem, we can see the consciousness gap of technicians
- Information system project managers must recite the core examination site (50). The contract content is not clearly stipulated
- Illustration of the insertion process of b+ tree
- [C] Explain language file operation in detail
- How to effectively prevent others from wearing the homepage snapshot of the website
- (Dynamic Programming Series) sword finger offer 48. the longest substring without repeated characters
猜你喜欢

Games101 review: rasterization

HLS Experiment 1 -- multiplier

massCode 一款优秀的开源代码片段管理器

循环与分支(一)

Wechat applet - get user location (longitude and latitude + city)

Prometheus+blackbox exporter+grafana monitoring server port and URL address

ES6 advanced - using prototype object inheritance methods
![[steering wheel] tool improvement: common shortcut key set of sublime text 4](/img/51/fe95e95ccd5cd6406f3b49e3bdba3f.png)
[steering wheel] tool improvement: common shortcut key set of sublime text 4

MySQL建Websites数据表

Adruino basic experimental learning (I)
随机推荐
富文本转化为普通文本
eslint常见报错集合
Games101 review: rasterization
How to speed up matrix multiplication
What can EAM system help enterprises do?
scipy.sparse.csr_ matrix
DFS Niuke maze problem
循环与分支(一)
墨天轮高分技术文档分享——数据库安全篇(共48个)
How can users create data tables on Web pages and store them in the database
Self-supervised learning method to solve the inverse problem of Fokker-Planck Equation
[steering wheel] use the 60 + shortcut keys of idea to share with you, in order to improve efficiency (reconstruction)
JS get the time composition array of two time periods
The sixth day of the third question of daily Luogu
numpy.sort
18_ Request file
AMD64(x86_64)架构abi文档:中
MySQL(4)
U++ print information to screen and log
TCP three handshakes and four waves