SHELL 命令
下面 class 代表数据库名称
创建新表
Create table class(name char[32],sex char[2],score int);
删除表
Drop table class;
查询表所有记录
Select * from class;
查询指定记录
Select * from class where name = "zhangsan";
添加纪录
Insert into class values ("zhangsan","nv",100);
删除记录
Delete from class where name = "zhangsan"
更新记录
Update class set sex = "nan" where name = "zhangsan";
C语言接口
#include <sqlite3.h>
Sqlite3 *db;
Char *errmsg;
Int sqlite3_open("gp.db",&db);
返回值0与非零值;
Int sqlite3_close(db);
返回0与错误码;
If((Sqlite3_exec(db,"命令",callback,NULL,&errmsg)) != SQLITE_OK)
{
printf("error : %s\n",errmsg);
Sqlite3_free(errmsg);
}
返回值0或者错误码;
Callback 返回0与非零,返回非零时 sqlite3_exec 返回 SQLITE_ABORT;
以上代码是测试数据库查询一项时,callback调用参数f_num f_value f_name 返回的数据;