int ret = sqlite3_open("628demo.db",&datb1);
打开628demo.db数据库,datb1为句柄
char str3[1024] = {"create table "};
char * str11 = "Listqwe";
strcat(str3,str11);
char *str2 = "(id int primary key,name text,age text )";
strcat(str3,str2);
char sql[1024] = {0};
sprintf(sql,"drop table if exists %s",str11);
sqlite3_exec(datb1,sql,NULL,NULL,&errmsg); //在创建表时,如果表存在,则删除
ret = sqlite3_exec(datb1,str3,NULL,NULL,&errmsg);
创建表 create table Listqwe (id int primary key,name text,age text )
ret = sqlite3_get_table(datb1,"select * from Listqwe",&dbresult,&nrow,&ncolumn,&errmsg);
查看页表中数据
ret = sqlite3_exec(datb,"alter table wwwww rename to ererer",NULL,NULL,&errmsg);
修改表名
ret = sqlite3_get_table(datb,"select name from sqlite_master where type ='table'order by name ",&dbresult,&nrow,&ncolumn,&errmsg);
查看当前数据库下有那几个表
sqlite3_exec(datb,"update demoF set name = 'lijilei' where name = 'li'",NULL,NULL,&errmsg);
修改记录
ret = sqlite3_get_table(datb1,"select * from List left join List1 on List.id = List1.id ",&dbresult,&nrow,&ncolumn,&errmsg);
多表查询
"insert into List values('1','zhang','12')";
增加记录
sqlite3_exec(datb,"delete from demoF where id = 3",NULL,NULL,&errmsg);
删除记录
ret = sqlite3_get_table(datb,"select * from demoF order by id desc",&dbresult,&nrow,&ncolumn,&errmsg);
按id倒序
ret = sqlite3_exec(datb,"drop table if exists demoF",NULL,NULL,&errmsg);
删除表
ret = sqlite3_close(datb);
关闭数据库