DML(data manipulation language):数据操作语言针对数据表中行进行操作
增insert
插入单行数据
insert [into] t_name [(col_name,.....)] values(val,.....);
插入多行数据
insert [into] t_name [(col_name,.....)] values(val1,.......),(val1,.....);
删delete
delete from tb_name [where clause];
改update
update t_name set col_name1=value,col_name2=value [where clause];
查select
select col1,col2,.... from t_name [where clause] [order by 'col_name' [desc]] [limit [m,]n];
字段表示法
*:所有字段
as:字段别名,col1 AS alias1
order by
排序查找(默认升序) 降序接DESC
limit
字符限制查找(只显示其中部分内容),可以偏移限制查找。)
Limit 3 <==> limit 0,3
where clause 条件表示
字段后接比较式(除等于,其他仅局限于数值型)
> , = , < , >= , <= , !=
条件逻辑操作
And 而且
Or 或者
Not 非
between ... and ...(相当于>=和<=之间)
空值比较或匹配
IS NULL (子句内元素为空)
IS NOT NULL (子句内元素为非空)
LIKE(模糊匹配)
%:任意长度任意字符
_:任意单个字符