当前位置 博文首页 > xixi:sqlite3 判断表是否存在

    xixi:sqlite3 判断表是否存在

    作者:[db:作者] 时间:2021-08-07 18:55

    - (BOOL) isExistTable:(NSString *)tableName
    {
        FMResultSet *rs = [self.db executeQuery:@"select count(*) as 'count' from sqlite_master where type ='table' and name = ?", tableName];
        while ([rs next])
        {
            // just print out what we've got in a number of formats.
            NSInteger count = [rs intForColumn:@"count"];
            NSLog(@"isTableOK %ld", count);
            
            if (0 == count)
            {
                return NO;
            }
            else
            {
                return YES;
            }
        }
        
        return NO;
    }


    cs
    下一篇:没有了