我想为SQLite中的字段分配null
,但与此无关:
update t set n=null where n=0;
I can not reproduce your problem. From what you write, I guess your table looks like this:
CREATE TABLE t (n integer);
Inserting data:
insert into t values (1);
insert into t values (2);
insert into t values (3);
insert into t values (0);
Updating the data with your UPDATE
:
update t set n = null where n = 0;
Now the table looks like this:
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE t (n integer);
INSERT INTO "t" VALUES(1);
INSERT INTO "t" VALUES(2);
INSERT INTO "t" VALUES(3);
INSERT INTO "t" VALUES(NULL);
COMMIT;
There might be no output after the UPDATE
but it has the desired effect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.