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);
let tableName = "myTable"
let deleteStatementString = "DELETE FROM \(tableName);"
var deleteStatement: OpaquePointer? = nil
if sqlite3_prepare_v2(db, deleteStatementString, -1, &deleteStatement, nil) == SQLITE_OK {
if sqlite3_step(deleteStatement) == SQLITE_DONE {
print("Successfully deleted all rowns from \(tableName)")
} else {
print("Could not delete all rowns from \(tableName)")
}
} else {
print("DELETE statement could not be prepared")
}
sqlite3_finalize(deleteStatement)
6条答案
按热度按时间ee7vknir1#
执行此操作的常规SQL语法:
zrfyljdw2#
SQLite Documentation 。 在 iOS 中 删除 行 :
中 的 每 一 个
cvxl0en23#
如果要从SQL表中删除所有行,请转到
如果要逐个删除行,则转到
根据您的要求更改id,或者您也可以指定要删除其行的特定字段名称
wxclj1h54#
zynd9foi5#
l5tcr1uw6#
在Swift中,您可以这样做: