sqlite3

#查看命令行帮助

.help

#查看加载的数据库文件:

.database

#查看当前加载的数据库文件的表的名称

.tables

#查看所有的表的结构:

.schema --indent

#查看training表的结构:

.schema --indent training

 

#从images表中查询md5匹配71ddfe74ed1dbb3818c3039450bb7878的数据的id,md5,groupName,feature

select id,md5,groupName,feature from images where md5 like '%71ddfe74ed1dbb3818c3039450bb7878%';

注意:其中%为通配符,代表缺省的字符串; 最末尾处有分号表示该语句结束

 

#从images表中,查询groupName等于5b73e95bc4432700086fe4a5并且md5匹配bb7878的数据条目的总条数

SELECT count(*) FROM images WHERE groupName='5b73e95bc4432700086fe4a5' AND md5 LIKE '%bb7878%'

#从images表中,查询groupName等于yxgroup的数据

select  id,md5,groupName from images where groupName='yxgroup';

#从images表中,删除groupName等于yxgroup的数据

delete from images where groupName='yxgroup';

#在数据删除后压缩数据库文件的空间,大致原理为清除空列

VACUUM;

参考:https://www.cnblogs.com/samlin/p/5580191.html

 

#order by, limit, desc, asc,desc的使用

#order by 以哪个字段排序,默认是升级,即默认为asc

#limit为:当查询有多条记录时,最多显示的记录条数

#desc为降序

select id,md5 from images order by id asc limit 10;

select id,md5 from images order by id desc limit 10

 

posted @ 2018-11-23 09:45  rootid  阅读(215)  评论(0)    收藏  举报