[英]how to assign null to a field in sqlite
我想为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
更新数据:
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. UPDATE
之后可能没有输出,但具有预期的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.