Deleting an entry and releasing from unique key index

允我心安 提交于 2019-12-25 04:59:26

问题


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

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.


回答1:


I think there are a few possibilities here.

  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.

  2. 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.

  3. You have a corrupt index and need to reindex it.



来源:https://stackoverflow.com/questions/10854906/deleting-an-entry-and-releasing-from-unique-key-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!