假设我在Sqlite中有一个表:
MySingleRowtable:
+--------------+
| someHeader | <-----pk
+--------------+
| aa |
+--------------+
如何更新主键的值?
我尝试过:
UPDATE MySingleRowtable
SET 'someHeader' = 'bb'
WHERE 'someHeader'='aa';
答案 0 :(得分:0)
以下作品:-
DELETE FROM MySingleRowTable;
CREATE TABLE IF NOT EXISTS MySingleRowTable (someHeader PRIMARY KEY);
INSERT OR IGNORE INTO MySingleRowTable VALUES('aa');
SELECT * FROM MySingleRowTable;
UPDATE MySingleRowTable SET someHeader = 'bb' WHERE someHeader = 'aa';
SELECT * FROM MySingleRowTable;
但是,您有:-
DELETE FROM MySingleRowTable;
CREATE TABLE IF NOT EXISTS MySingleRowTable (someHeader PRIMARY KEY);
INSERT OR IGNORE INTO MySingleRowTable VALUES('aa');
SELECT * FROM MySingleRowTable;
UPDATE MySingleRowTable SET 'someHeader' = 'bb' WHERE 'someHeader' = 'aa';
SELECT * FROM MySingleRowTable;
也就是说,列名用单引号引起来,所以您实际上是在说
相对于