当前位置:网站首页>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 19:33:00 【Software testing】
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
select
`id`
,`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 .
A little help
Finally, thank everyone who reads my article carefully , Watching the rise and attention of fans all the way , Reciprocity is always necessary , Although it's not very valuable , If you can use it, you can take it !
The house needs to be built layer by layer , Knowledge needs to be learned at one point one . We should lay a good foundation in the process of learning , More hands-on practice , Don't talk much , The last dry goods here ! I stayed up late to sort out the stages ( function 、 Interface 、 automation 、 performance 、 Test open ) Skills learning materials + Practical explanation , Very suitable for studying in private , It's much more efficient than self-study , Share with you .
Get off w/x/g/z/h: Software testing tips dao
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 .
边栏推荐
- ReentrantLock学习之---释放锁过程
- 从6月25日考试之后,看新考纲如何复习PMP
- Here comes the most complete introduction to MES system
- 深度学习的数学基础
- Tensorflow-GPU 1.15安装
- How to write the test case of mobile app? What are the mobile app test points?
- Synchronized理论
- Spatiotemporal prediction 4-graph WaveNet
- 时空预测4-graph wavenet
- Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
猜你喜欢

Usage scenarios for automated testing

C # upper computer development - modify the window icon and exe file Icon

深度学习的数学基础

还在用Xshell?你out了,推荐一个更现代的终端连接工具

彻底关闭win10自动更新

【C语言实现】----动态/文件/静态通讯录

J3: redis master-slave replication

The role of @requestmapping in the project and how to use it

J2 Redis之 AOF&RDB
![[MySQL from introduction to proficiency] [advanced chapter] (VIII) clustered index & non clustered index & joint index](/img/18/1644301d575fad0a0d0f15932487d0.png)
[MySQL from introduction to proficiency] [advanced chapter] (VIII) clustered index & non clustered index & joint index
随机推荐
周末看点回顾|数字人民币产业联盟成立;中国移动宣布:和飞信将停止服务…
Write a starter
(ICLR-2022)TADA! Time adaptive convolution for video understanding
Gongfu developer community is settled! On July 30!
(ICLR-2022)TADA!用于视频理解的时间自适应卷积
彻底关闭win10自动更新
Distributed transaction Seata
[skim] two point answer solution
The passwords are consistent, and the total display is as shown in the figure below
JVM内存模型之Volatile关键字
Difficult performance problems solved in those years -- ext4 defragmentation
Here comes the most complete introduction to MES system
Tensorflow GPU 1.15 installation
LeetCode笔记:Biweekly Contest 83
[MySQL from introduction to proficiency] [advanced chapter] (VIII) clustered index & non clustered index & joint index
"Weilai Cup" 2022 Niuke summer multi school training camp 2
博客维护记录之图片预览嵌入位置问题
CONDA transfer project virtual environment essential skills +pip speed download too slow solution
A case study of building an efficient management system for a thousand person food manufacturing enterprise with low code
这22个绘图(可视化)方法很重要,值得收藏!