//创建表,总函数
int createTable(sqlite3* db)
{
if (!db)
return -1;
char tblName[64];
char fields[128], indexs[64];
sprintf(tblName, "%s", "personInfo");
sprintf(fields, "id int, name text, phoneNum text, address text, other text");
sprintf(indexs, "name, phoneNum");
if (isTableExist (db, tblName))
{
change_table(db, tblName, fields, indexs);
return 0;
}
int ret = CreateTable (db, tblName, fields, indexs);
if (ret != SQLITE_OK)
return -1;
return 0;
}
//检查表是否存在
int isTableExist (sqlite3* db, const char* table)
{
char sql[128];
sprintf (sql, "select * from sqlite_master where type='table' and name='%s'", table);
int ret = -1;
sqlit