2010-05-20 177 views

回答

0

如果您直接使用SQLite C API(您不應該這樣做),則可以使用sqlite_column_name()函數來獲取給定索引的列名稱。這適用於sqlite_column_count()函數。

如果您使用Flying Meat Database包裝(您應該),您可以執行PRAGMA table_info(myTable),然後遍歷ResultSet。列名稱在索引1.換句話說:

FMResultSet * infoRS = [db executeQuery:@"PRAGMA table_info(myTable)"]; 
while ([infoRS next]) { 
    NSLog(@"Column #%d: %@", [infoRS intForColumnIndex:0], [infoRS stringForColumnIndex:1]); 
}