部门现在做一个新的项目,今天产品刚给到需求,需求也是处于和合作公司对接状态,目前时间不是那么紧张,那么我自己也是一边整理下工作中常用sql语句,做一个总结。
作为测试目前用得较多的就是一些基本的增删改查等操作,测试中重点在于把握前端添加数据或点击操作时写入表是否同步,写入的时间点是否正确,修改数据时能否同步更新到表,相关联的表操作时的相互作用影响等,这些都是需要注意测试覆盖的地方。这篇只对工作中常用做整理,高级的关联查询语句在下一篇再进行添加。
选择:select * from table1 where 范围
插入:insert into table1(field1,field2) values(value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1=value1 where 范围
查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料
排序:select * from table1 order by field1,field2 [desc]
总数:select count * as totalcount from table1
求和:select sum(field1) as sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(field1) as minvalue from table1