
常用函数
SQL Injection Common Functions
本页目录 / On this page
常用系统函数:
| 基础信息函数 |
功能 |
| system_user() |
系统用户名 |
| user() |
用户名 |
| current_user() |
当前用户名 |
| session_user() |
连接数据库的用户名 |
| database() |
数据库名 |
| version() |
数据库版本 |
| @@datadir |
数据库路径 |
| @@basedir |
数据库安装路径 |
| @@version_compile_os |
操作系统 |
| count() |
返回执行结果数量 |
| sleep() |
不用解释 |
常用其他函数:
三个重点字符串函数介绍参考:***.com
| 字符处理函数 |
功能 |
举例 |
| 重点 concat() |
没有分隔符地连接字符串 |
select concat(c1,c2) from xxx |
| 重点 concat_ws() |
指定分隔符地连接字符串 |
select concat_ws(':',c1,c2) from xxx |
| 重点 group_concat() |
以逗号分隔某列/组的数据 |
select group_concat(c1,c2) from xxx |
| load_file() |
读取服务器文件 |
select loadfile('/tmp/a.txt') |
| into outfile |
写入文件到服务器 |
select 'xxxx' into outfile '/tmp/a.txt' |
| ascii() |
字符串的ASCII代码值 |
select ascii('a') |
| ord() |
返回字符串第一个字符的ASCII值 |
select ord('abc') |
| char() |
返回ASCII值对应的字符串 |
select char(97) |
| mid() |
返回一个字符串的一部分 |
select mid('abcde',1,1) |
| substr() |
返回一个字符串的一部分 |
select substr('abcde',1,1) |
| length() |
返回字符串的长度 |
select length('abc') |
| left() |
返回字符串最左面几个字符 |
select left('mysql',2) |
| floor() |
返回小于或等于X的最大整数 |
select floor(5.1) |
| rand() |
返回0-1间的一个随机数 |
select rand() |
| if() |
三目运算 |
select if(1>2,'A','B') |
| strcmp() |
比较字符串ASCII大小 |
select strcmp('c','b') |
| ifnull() |
参数1为不null则返回参数1,否则参数2 |
select ifnull(null,2) |
|
|
|