使用表的别名,如此能够减少表字段的输入错误,而且多表联查时避免相同字段的歧义。 如select * from vehicle t where t.hpzl='02'
where 后的条件执行时是从后往前,因此能够筛选更多数据的条件排在后面。
查询尽量用确定的列名,少用*号。比如:select count(key)from tab where key> 0性能优于select count(*)from tab;
将or换为in。 比如 select * from vehicle where syxz in ('R','O')性能优于select * from vehicle where syxz='R' or syxz='O'
将>,<替换为>=,<=;
避免对字段使用函数等操作。比如:使用select * from vehicle where ccdjrq=to_date('2019-1-1','yyyy-mm-dd')而不是 select * from vehicle where to_char(ccdjrq,'yyyy-mm-dd')='2019-1-1'