sqlite创建新表
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlite创建新表相关的知识,希望对你有一定的参考价值。
Source creating a new database (and inserting some records)
#include <sqlite3.h> #include <stdio.h> #define safe_exit() sqlite3_close(db);db=0;return 0 #define _tempdb "temp.db" int error; int main() { sqlite3 *db; char sql[300]; char *err_msg; error = sqlite3_open(_tempdb, &db); if(error!=SQLITE_OK) { safe_exit(); } error = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS "memory" ("order" INTEGER PRIMARY KEY,"address" INTEGER,"size" INTEGER,"file" TEXT NOT NULL,"line" INTEGER,"typ" INTEGER);", 0, 0, 0); if(error!=SQLITE_OK) { safe_exit(); } sprintf(sql,"INSERT INTO "memory" ("address","size","file","line","typ") VALUES (1442040,20,'fname',22,1);"); error = sqlite3_exec(db, sql, 0, 0, &err_msg); if(error!=SQLITE_OK) { } safe_exit(); }
以上是关于sqlite创建新表的主要内容,如果未能解决你的问题,请参考以下文章