
介绍
在Mysql 5.0以上的版本中,默认定义了information_schema数据库,用来存储数据库元信息,其中具有表schemata(数据库名),tables(表明),columns(列名或字段名)
在schemata表中,schema_name字段用来存储数据库名,
在tables表中,table_schema和table_name分别用来存储数据库名和表名。
在columns表中,table_schema(数据库名),table_name(表名),column_name(字段名)
数据库的增删改查
查
1
| select 列名称 或 * from 表名称 where 字段1='条件1' and 字段2='条件2'
|
增
1
| insert into table name(列1,列2 ...) values(值1,值2)
|
改
1
| update 表名称 set 列名称=新值 where 列名称=某值
|
删
1
| delete from 表名称 where 列名称=值
|
Mysql中常用的聚合函数
- user():查看当前Mysql登录用户名
- database():查看当前使用Mysql数据库名
- version():查看当前Mysql版本
limit关键字
limit m,n :从m行开始,到m+n行。
1
| selsct * from admin limit 2,1
|
注释
注释符:
内联注释
/*!SQL 语句 */ (只有Mysql可以识别,常用来绕过WAF)
1 2
| 常规:select * from articles where id=id 内联注释:select * from articles where id= -1 /*!union *//*!select*/1,2,3,4
|