0

这就是我得到的:

CREATE TABLE IF NOT EXISTS Settings (sitem TEXT, ccolor TEXT, ncolor TEXT)
CREATE UNIQUE INDEX IF NOT EXISTS sindex ON Settings (sitem, ccolor, ncolor)

但是当我尝试插入一个值然后运行它替换它时:

INSERT OR REPLACE INTO Settings (sitem) VALUES ("something")
INSERT OR REPLACE INTO Settings (sitem) VALUES ("something else")

这是我在sitem专栏中得到的:

     sitem
---------------
something
something else

它不会取代它,即使它是唯一的,也只是创造另一个价值,有什么帮助吗?

4

1 回答 1

0

The sitem field is part of the primary key and so is used to identify the row to do the replace on. You can't update the row in the way you want because the database can't tell that you want to replace the first record with the second one, so it does an insert instead.

于 2013-03-31T21:58:18.133 回答