每天更新

explain select
explain 分析sql语句的查询效率 执行计划详解

 

distinct和group by都是对重复数据进行屏蔽,只显示一条该重复数据

 

order by排序
order by 字段 desc 降序排序
order by 字段 asc 升序排序

 

max(字段) 查询表中字段最大的

 

limit m,n 表示 从第m+1条数据开始,取n条记录

 

as 对字段别名定义

 

length() 获取字符串

 

replace(X,Y,Z) X:要处理的字符串 Y:被替换的字符串 Z:替换后的字符串 例如replace("10,A,H" , "," ,"") 将"10,A,H"字符串中的逗号替换成空 为了方便观察 加了很多空格 实际没有

 

 

intersect 求两个表中的交集
select * from table1 intersect select * from table2

 

 

在 SQLite 系统表 sqlite_master 中可以获得所有表的索引,其中字段 name 是所有表的名字,而且对于自己创建的表而言,字段 type 永远是 'table'
在 SQLite 中用 “||” 符号连接字符串
select "select count(*) from" || name || ";" as cnts from sqlite_master where type='table'

 

posted on 2018-07-19 17:24  猿分  阅读(66)  评论(0编辑  收藏  举报