FMDB
// 需要先创建数据库文件保存目录
if (![fileManager fileExistsAtPath:myPath]) {
[fileManager createDirectoryAtPath:myPath withIntermediateDirectories:YES attributes:nil error:nil];
}
// 拼接数据库路径
NSString *dbPath = [maskFilePath stringByAppendingPathComponent:@"user.sqlite"];
// 创建数据库
_dataBase = [FMDatabase databaseWithPath:dbPath];
NSString *sql = [NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS UserDataTable(u_id INTEGER PRIMARY KEY AUTOINCREMENT, u_address TEXT)"];
BOOL result = [_dataBase executeUpdate:sql];
[db executeUpdate:DDYStrFormat(@"CREATE INDEX IF NOT EXISTS index2 ON %@ (messageID)",tableName)];
网友评论