经查实,发现不是sql语句的语法错误,。。而是我批量加载sql文件的时候,文件名出错啦,数据库找不到我这个文件名。
//1.根据路径 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *docDir = [paths objectAtIndex:0]; NSString *fileName = [docDir stringByAppendingString:@"/teamtalk"]; NSLog(@"数据库的路径是:%@",fileName); //2.获得数据库 FMDatabase *db = [FMDatabase databaseWithPath:fileName]; if([db open]) { for(int i = 0;i<9;i++) { NSString *str = [NSString stringWithFormat:@"a00%d",i+1]; NSString *filePath = [[NSBundle mainBundle] pathForResource:str ofType:@"sql"]; NSError *error1; NSString * sql2 = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error1]; BOOL result2 = [db executeUpdate:sql2]; if (result2) { NSLog(@"success a00%d",i+1); } }原文链接:https://www.f2er.com/sqlite/199109.html