删除条目并从唯一键索引中释放 [英] Deleting an entry and releasing from unique key index

查看:55
本文介绍了删除条目并从唯一键索引中释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于具有离线存储的项目,我创建了一个数据库,其中包含 id 的主键和保存日期的唯一字段.

For a project with offline storage, I created a database with a primary key for the id and also a unique field holding the date.

当我删除一个条目时,我无法创建一个与已删除条目日期相同的新条目.

When I delete an entry, I can not create a new one with the same date the deleted entry had.

当我删除该条目时,如何从索引中获取日期?

What can I do to get the date out of the index when I delete that entry?

这就是我创建表格的方式:

This is how I create Table:

CREATE TABLE IF NOT EXISTS userdata (id INTEGER PRIMARY KEY ASC, entrydate DATE UNIQUE, strength, comments

我想知道我是否需要添加一些东西来告诉数据库服务器允许我在它再次空闲时再次使用相同的值.也许我需要运行某种更新,SQLite 更新其内部记录.

I wonder if I need to add something to tell the DB server to allow me to use the same value again as soon it is free again. Maybe I need to run some kind of an update, where SQLite updates its internal records.

推荐答案

我认为这里有一些可能性.

I think there are a few possibilities here.

  1. 您的删除语句位于未提交的事务中.因此,在您尝试插入之前,该唯一值实际上并未从表中删除.

  1. Your delete statement is in an uncommitted transaction. So the unique value hasn't actually been removed from the table before your attempt to insert.

您要删除的值和您插入的新值实际上并不是同一个值.运行选择并确保您尝试插入的值实际上可用.

The value you are deleting and the new value you are inserting are not actually the same value. Run a select and make sure the value you are attempting to insert is actually available.

您的索引已损坏,需要重新编制索引.

You have a corrupt index and need to reindex it.

这篇关于删除条目并从唯一键索引中释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆