当前位置:网站首页>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 .
边栏推荐
- 洋葱集团携手OceanBase实现分布式升级,全球数据首次实现跨云融合
- SEO, client rendering ', server rendering, search engine understanding
- 节省50%成本 京东云发布新一代混合CDN产品
- Is it safe for CSC qiniu members to open preferential accounts? I don't know if it's the lowest Commission
- torch.unsqueeze() squeeze() expand() repeat()用法及比较
- AttributeError: ‘Upsample‘ object has no attribute ‘recompute_ scale_ factor‘
- Customer cases | focus on process experience to help bank enterprise app iteration
- "Weilai Cup" 2022 Niuke summer multi school training camp 2
- To add a composite primary key
- 配置服务器环境
猜你喜欢

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

MapReduce (II)
密码一致,总显示如下图

PMP每日一练 | 考试不迷路-7.26(包含敏捷+多选)

Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release

“蔚来杯“2022牛客暑期多校训练营1

Reentrantlock learning --- basic method

AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘

ReentrantLock学习之公平锁过程

J1: why is redis so fast + basic structure
随机推荐
Difficult performance problems solved in those years -- ext4 defragmentation
“蔚来杯“2022牛客暑期多校训练营1
"Weilai Cup" 2022 Niuke summer multi school training camp 2
TypeScript阶段学习
(ICLR-2022)TADA!用于视频理解的时间自适应卷积
TB 117-2013美国联邦强制性法规
中信建投启牛会员优惠开户安全吗,不知道是不是最低的佣金
用低代码搭建千人食品制造企业高效管理系统案例分析
Briefly describe the 11 core functional modules of MES system
A case study of building an efficient management system for a thousand person food manufacturing enterprise with low code
测试人员必须知道的软件流程
Cannot find current proxy: Set ‘exposeProxy‘ property on Advised to ‘true‘ to make it available
Tensorflow GPU 1.15 installation
博客维护记录之图片预览嵌入位置问题
LeetCode笔记:Biweekly Contest 83
The difference between advanced anti DDoS server and advanced anti DDoS IP
2022搭建企业级数据治理体系
Turn off win10 automatic update completely
C # upper computer development - modify the window icon and exe file Icon
自动化测试的使用场景