sqlite
来源:互联网 发布:web前端开发必备软件 编辑:程序博客网 时间:2024/05/19 19:29
安装sqlite,使用lib.exe运行sqlite3.def,
LIB /MACHINE:IX86 /DEF:sqlite3.def
生成sqlite3.lib
新建MFC工程,把sqlite3.h、sqlite3.dll、sqlite3.lib放到工程文件夹里
在链接模块后面加上sqlite3.lib,开始测试。
cmd cd sqlite3.exe所在的目录
建库 sqlite3 test.db
查表是否存在 select count(*) from sqlite_master where type = 'table' and name = 'tablename';
添加 insert into tablename values(1, 'test');
查询 select * from tablename;
更新 update tablename set col2 = '123' where col1 = 1;
删除 delete from tablename where col1 = 1;
删表 drop table tablename;
清空 delete from tablename;
退出 ctrl+c;
建表 create table tablename(col1 integer, col2 text);
修改表名 alter table tablename rename to newtablename
清空表主键自增归零
SQL方法:truncate table 表名,但是sqlite不支持,sqlite将采用如下方法
1:delete from '表名'
2:执行下列语句中的任意一条
update sqlite_sequences set seq = 0 where name = '表名'
delete from sqlite_sequence where name = '表名'
查询最新几条记录
sqlserver采用的是:select top n from tablename where *** order by id desc
sqlite采用的是:
N1表示跳过多少行,也就是从第几行开始
N2表示取多少行
select * from tablename where *** order by id limit N1 offset N2
sqlite中的字符串都是UTF8格式的。
采用codeproject上的老外写的C++封装类CppSQLite3DB,详见代码。
在偶然一次数据库路径名为中文名时,打开数据库报错,经调试,所有的SQL语句必须是UTF-8编码格式,调用之前都要将ANSI转换成UTF-8。
函数说明:
int execDML(const char* szSQL);增删改调用此函数,该函数返回最近执行的INSERT、UPDATE和DELETE语句所影响的数据行数。
- SQLite
- SQLite
- SQLite
- SQLite
- SQLite
- sqlite
- sqlite
- SQLite
- SQLite
- sqlite
- SQLite
- SQLite
- SQLite
- SQLite
- SQLite
- sqlite
- sqlite
- sqlite
- 旧手机也可以变宝贝,95%的人不知道!
- [leetcode]151. Reverse Words in a String
- hdu4616(树形dp)
- 通过Reactivecocoa绑定UISwitch到NSUserDefault
- 二级菜单总结
- sqlite
- RecyclerView的基本使用
- Jsp的四大作用域与九大对象
- 复制构造函数
- Ehcache memcache redis 三大缓存
- java语言中不允许嵌套定义
- n皇后问题(简单dfs)
- Thread详解13:ReentrantLock的用法(一)
- 第八届河南省程序设计大赛-NYOJ-1238-最少换乘