当前位置:网站首页>Database basics exercise part 2
Database basics exercise part 2
2022-07-06 06:45:00 【Lu__ xiao】
MYSQL(MariaDB) Advanced operation
- order by Usage of
select * from result order by score desc;
take result Data installation scores in the table (score) Sort high and low
among ,desc Representation of descending order ( Decline ); If from low to high ( Ascending ) Arrange , Then you can put desc Switch to asc; If you don't add this parameter , By default, they are arranged in ascending order
select id,name,score from result order by 1;
take result The data in the table is displayed by id Sort
select id,name,score from result order by 2;
take result The data in the table is displayed by name Sort
select id,name,score from result order by 3;
take result The data in the table is displayed by score Sort
select id,name,score from result order by 4;
Prompt error No fourth column
order by Back number (M) Must be less than n( Number of fields in database query ) To display properly . If M>N, The database will report an error
- Limit Usage of
Limit M,N // Says from the first M+1 Data began to look down N Data
Limit M // Indicates before query M Data
select * from result limit 0,2;
The first... In the query table 2 Data
select id,name,score from result limit 1,3;
From 2 Data starts , Go down to query 3 Of data id、name and score Field
- union select Usage of
(1)select * from result union select 1,2,3,4;
The query result of this statement , That is select * from result and union select 1,2,3,4 Splicing of query results
(2) Try the following 3 statement :
select id,name,score from result union select 1,2,3;
Normal display
select id,name,score from result union select 1,2;
Report errors
select id,name,score from result union select 1,2,3,4;
Report errors
The above results are summarized , For the following commands :
Select c1,c2…,cn from result union select d1,d2,…dm;
The second half of the sentence union select Number of fields queried (M) Must be the same as the first half of the sentence select Number of fields queried (n) equal , The database can display the results normally . And order by be similar , This feature can be used to judge the number of fields queried in the database .
(3) Try the following statement
select id,city from result where id=1 and 1=2 union select name,score from result;
From the above results, we can sum up , When the field name is known , An attacker simply places the field anywhere it can be displayed , You can expose the value of this field 、
- union select combination information_schema database
MySQL (MariaDB) 5.5 The above version comes with information schema database , It's about MySQL Information about all other databases maintained by the server , Such as database name, database table 、 Data type and access right of table column . You can put information schema Database as MySQL (MariaDB) Of ” Catalog "!
- Try to execute the following two statements
Show databases;
Select schema_name from information_schema.schemata;
The execution results of the two statements are the same
(2) Try to execute the following two sets of statements
The first group
Use student;
The second group
select table_name from information_schema.tables where table_schema='student';
The execution results of the two groups of commands are the same
边栏推荐
- In English translation of papers, how to do a good translation?
- Introduction and underlying analysis of regular expressions
- [ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
- Thesis abstract translation, multilingual pure human translation
- Reflex WMS中阶系列3:显示已发货可换组
- Biomedical localization translation services
- [English] Grammar remodeling: the core framework of English Learning -- English rabbit learning notes (1)
- Fledgling Xiao Li's 103rd blog CC2530 resource introduction
- 中英对照:You can do this. Best of luck祝你好运
- ECS accessKey key disclosure and utilization
猜你喜欢
Fedora/rehl installation semanage
Biomedical English contract translation, characteristics of Vocabulary Translation
机器学习植物叶片识别
ECS accessKey key disclosure and utilization
CS通过(CDN+证书)powershell上线详细版
机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
LeetCode - 152 乘积最大子数组
How to do a good job in financial literature translation?
My daily learning records / learning methods
E-book CHM online CS
随机推荐
CS通过(CDN+证书)powershell上线详细版
成功解决TypeError: data type ‘category‘ not understood
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Engineering organisms containing artificial metalloenzymes perform unnatural biosynthesis
利用快捷方式-LNK-上线CS
Day 248/300 thoughts on how graduates find jobs
Changes in the number of words in English papers translated into Chinese
Difference between backtracking and recursion
Financial German translation, a professional translation company in Beijing
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
L'Ia dans les nuages rend la recherche géoscientifique plus facile
Machine learning plant leaf recognition
Modify the list page on the basis of jeecg boot code generation (combined with customized components)
How much is it to translate Chinese into English for one minute?
基於JEECG-BOOT的list頁面的地址欄參數傳遞
一文读懂简单查询代价估算
专业论文翻译,英文摘要如何写比较好
雲上有AI,讓地球科學研究更省力
Bitcoinwin (BCW): 借贷平台Celsius隐瞒亏损3.5万枚ETH 或资不抵债
LeetCode 729. My schedule I