XCODE SQLITE3自动增量删除和更新
我查阅了一些关于删除SQLITE3表中的条目的在线资源,我认为我做得不对,因为输出似乎不正确 示例:定义了ID自动增量主键。所以我有id=1,2,3,4。在删除(id=3)之后,在新插入时,我实际上得到了1,2,4,5,而不是1,2,3,4 谁能帮我解释一下吗?下面是我的代码 p/s:我尝试了几种方法,这就是为什么您可以看到注释命令的原因XCODE SQLITE3自动增量删除和更新,xcode,sqlite,sql-delete,Xcode,Sqlite,Sql Delete,我查阅了一些关于删除SQLITE3表中的条目的在线资源,我认为我做得不对,因为输出似乎不正确 示例:定义了ID自动增量主键。所以我有id=1,2,3,4。在删除(id=3)之后,在新插入时,我实际上得到了1,2,4,5,而不是1,2,3,4 谁能帮我解释一下吗?下面是我的代码 p/s:我尝试了几种方法,这就是为什么您可以看到注释命令的原因 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
BP * bp = [entries objectAtIndex:indexPath.row];
//[self deleteData:[NSString stringWithFormat:@"Delete from summary where name is '%s'", [bp.Diastolic UTF8String]]];
// [self deleteData:[NSString stringWithFormat:@"Delete from summary where id is '%s'", [bp.IDNumber UTF8String]]];
// [self deleteData:[NSString stringWithFormat:@"Delete from summary; delete from '%s' where name = summary",[bp.IDNumber UTF8String]]];
[self deleteData:[NSString stringWithFormat:@"Delete from summary; delete from sqlite_sequence where name = summary"]];
NSLog(@"Name %@ is deleted",bp.IDNumber);
[entries removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
-(void)deleteData:(NSString *)deleteQuery
{
char *error;
if (sqlite3_exec(db, [deleteQuery UTF8String], NULL, NULL, &error)==SQLITE_OK) {
NSLog(@"Entry deleted");
}else{
NSLog(@"Entry didn't delete");
}
}
1,2,4,5有什么问题?为什么您认为您需要连续ID?@CL。谢谢回复。这是为了自学,更好地理解sqlite。请参阅。@CL。我实际上已经读过了。在作业结束时,我需要生成类似以下()的内容—用于客户名称、销售人员名称和发票记录的表。然而,我不知道如果我删除一名销售人员(比如辞职),会发生什么,sqlite将如何处理客户名称和发票记录?不要依赖于ID的实际值。