Reputation: 995
I would like to assign null
to a field in SQLite but am not getting anywhere with this:
update t set n=null where n=0;
Upvotes: 3
Views: 31664
Reputation:
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.
Upvotes: 17