select sql from sqlite_master where type="table" and name="word";
4.创建表格
CREATE TABLE word
(id integer primary key autoincrement not null,
word text not null,
translate text not null,
ofGroup int not null,
difficulty intdefault0,
kk intdefault0,
analogue intdefault99999)
5.c/c++操作sqlite数据库
#include<stdio.h>#include<stdlib.h>#include<sqlite3.h>staticintcallback(void*NotUsed,int argc,char**argv,char**azColName){int i;for(i =0; i < argc ; i ++){printf("%s = %s\n",azColName[i],argv[i]?argv[i]:"NULL");}printf("\n");return0;}intmain(int argc,char** argv){
sqlite3 *db;char*zErrMsg =0;int rc;char*sql;
rc=sqlite3_open("word.db",&db);if(rc){fprintf(stderr,"Can't open database:%s\n",sqlite3_errmsg(db));}else{fprintf(stderr,"Opened database successfully\n");}
sql ="insert into CPlusPlus(question,answer) values("\
"'C++中,为什么需要定义析构函数为虚函数?',"\
"' 因为多态的存在,防止出现实现多态时候基类指针指向派生对象,如果析构函数不是虚函数,在delete对象的时候只会调用基类的析构函数,而不会释放派生类分配的一些资源'"\
");";
rc =sqlite3_exec(db,sql,callback,0,&zErrMsg);if(rc != SQLITE_OK){fprintf(stderr,"SQL error:%s\n",zErrMsg);sqlite3_free(zErrMsg);}else{fprintf(stdout,"Records created successfully\n");}sqlite3_close(db);return0;}