3.1退出命令 .exit .quit
3.2查看表 .table

查看了建立好的fruit1
3.3查看表的结构

下面是sql语句:
3.4创建表A:create table A(id integer , name text , age integer , score float);
3.5插入记录:insert into fruit1 values (1 , 'sa' , 20 , 13);
insert into fruit1 (id , name , score) values(1 , 'sa' ,20 ,13);
3.6删除一条记录:delete from fruit1 where name = 'sa' and score = 13;
3.7更新一条记录:update fruit1 set age = 20 where id = 1;
update fruit1 set age = 20 ,score = 13 where id = 1;
3.8增加一列:alter table fruit1 add column level char;
3.9删除一列:create table fruit2 as select id , name from fruit1;
drop table fruit1;
alter table fruit2 rename to fruit1;
3.10查看数据库记录:
select * from fruit1 where score >=0 and score <=50;
select * from fruit1;
select * from fruit1 where id = 1;
select * from fruit1 where id = 1 and name = 'sa'; //and or
select name , score from fruit1; //查询指定字段
3.11删除一张表:drop table fruit1;
四、sqlite3 数据库的API函数
4.1打开数据库
int sqlite3_open(
const char *filename; //数据库的名字
sqlite3 **ppDb; //函数的回传的句柄二级指针
);
返回值:成功为0 SQLITE_OK ,出错为错误码(const char sqlite3_errmsg(sqlite3 *db))里面的参数为句柄一级指针。
4.2关闭数据库
int sqlite3_close(sqlite3 *db); //参数为回传句柄一级指针

返回值:成功为0 SQLITE_OK ,出错为错误码(const char sqlite3_errmsg(sqlite3 *db))里面的参数为句柄一级指针。
4.3执行sql语句
int sqlite3_exec(
sqlite3 *db, //句柄的一级指针
const char *sql ,//sql语句的首地址
int (*callback)(void * arg ,int f_num,char ** f_value , char **f_name),
//callback 参数1:sqlite3_exec传递来的参数,参数2:列数,参数3:列的值的地址,参数4:列的名称的地址
void *arg,//为回调函数传递参数
char **errmsg //错误消息
);
只有在执行查询语句时、才会传参
返回值:成功时返回SQLITE_OK
4.4查询函数
int sqlite3_get_table(
sqlite *db, const char *sql, char* **result ,int *nrow ,int *ncolumn ,char** errmsg
);
db:数据库的句柄
sql:sql语句
**result:二维数组 存放查询结果
nrow:表的行数
ncolumn:表的列数
errmsg:存放错误信息
,