//创建表
-(void)createTable
{
//准备sql语句
NSString *createTablesql = @"CREATE TABLE IF NOT EXISTS 'student' ('number' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,'name' TEXT NOT NULL,'age' INTEGER NOT NULL,'gender' TEXT NOT NULL DEFAULT male)";
//c语言里的函数sqlite3_exec,为什么用NULL不用nil,因为nil属于OC,NULL属于c
int result = sqlite3_exec(db,createTablesql.UTF8String,NULL,NULL);
if (sqlITE_OK == result) {
NSLog(@"成功");
}else
{
NSLog(@"失败");
}
}
原文链接:https://www.f2er.com/sqlite/199302.html