sqlite3语法小结

SQLite3不支持的SQL语法请参考:http://hyshang.blog.163.com/blog/static/4594582220121311728522/

自己做过的测试:

在SQLite3中统计总的行数
select COUNT (*) AS linenum from Table_name
生成的结果有一行一列,字段名为linenum,内容为行数的字符串

在SQLite3中显示前N行
select * from table_name limit N

显示从第N条开始的M条记录
select * from table_name limit N,M //N序号从0开始
在sqlite3中构建rowid:
select rowid,* from table_name //最左边一列段名为rowid,从1开始
select rowid [as column_name] from table_name //只有一列段名为rowid,从1开始
sqlite不支持rownum,但是可以使用rowid和limit组合实现rownum的功能
sqlite rowid的功能参考:
http://www.sqlite.org/lang_createtable.html#rowid

删除某段范围的记录
delete from system where rowid in (select rowid from system limit N,M)

删除某表的所有行
delete from table_name
不支持 delete * from table_name
不支持 Truncate table name

关闭数据库之后调用free_table是安全的
邮件列表上的问题http://readlist.com/lists/sqlite.org/sqlite-users/3/17854.html
sqlite3_open();
sqlite3_get_table(...result....);
sqlite3_close();
sqlite3_free_table(result);

一次插入多行数据
INSERT INTO table_name (‘culumn_name1’, 'column_name2') VALUES (xxx,xxx),(xxx,xxx)
exp:
insert into CFG ('CfgName','CfgValue') VALUES ('days',365),('number',30000)

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能