清除表SQLite iOS中的所有行

Lig*_*ght 2 sqlite iphone objective-c ios

我需要你的帮助..如何从sqlite db中删除表中的所有行?请问您能说一步(不是一个一个)删除所有行.

pio*_*kuc 10

正常的SQL语法来执行此操作:

DELETE FROM tablename
Run Code Online (Sandbox Code Playgroud)


Vim*_*lan 8

可以使用SQLite文档处理任何SQLite语法查询

用于删除iOS中的sqlite表行以下代码

NSString *query = @"delete from yourTable";
const char *sqlStatement = [query UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
    // Read the data from the result row
    NSLog(@"result is here");
}

// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
Run Code Online (Sandbox Code Playgroud)

我想这可以解决你的问题