如何在TDengine数据库中使用更新选项等于2将指定字段更新为空?
how to update specified field to null with update option equals 2 in TDengine database?
通过在创建数据库时使用update = 2选项,我们可以更新指定的字段,我应该如何将这个字段更新为空?
taos> create database db update 2; [5/2934]
Query OK, 0 of 0 row(s) in database (0.008446s)
taos> use db;
Database changed.
taos> create table tb(ts timestamp, c1 int, c2 nchar(20));
Query OK, 0 of 0 row(s) in database (0.024248s)
taos> insert into tb values(now, 1, "beijing");
Query OK, 1 of 1 row(s) in database (0.008139s)
taos> select * from tb;
ts | c1 | c2 |
=========================================================================
2022-02-07 14:54:54.189 | 1 | beijing |
Query OK, 1 row(s) in set (0.001694s)
taos> insert into tb values("2022-02-07 14:54:54.189", 2, NULL);
Query OK, 1 of 1 row(s) in database (0.000608s)
taos> select * from tb;
ts | c1 | c2 |
=========================================================================
2022-02-07 14:54:54.189 | 2 | beijing |
Query OK, 1 row(s) in set (0.005644s)
因为update = 2
达不到你想要的,可以用update = 1
通过在创建数据库时使用update = 2选项,我们可以更新指定的字段,我应该如何将这个字段更新为空?
taos> create database db update 2; [5/2934]
Query OK, 0 of 0 row(s) in database (0.008446s)
taos> use db;
Database changed.
taos> create table tb(ts timestamp, c1 int, c2 nchar(20));
Query OK, 0 of 0 row(s) in database (0.024248s)
taos> insert into tb values(now, 1, "beijing");
Query OK, 1 of 1 row(s) in database (0.008139s)
taos> select * from tb;
ts | c1 | c2 |
=========================================================================
2022-02-07 14:54:54.189 | 1 | beijing |
Query OK, 1 row(s) in set (0.001694s)
taos> insert into tb values("2022-02-07 14:54:54.189", 2, NULL);
Query OK, 1 of 1 row(s) in database (0.000608s)
taos> select * from tb;
ts | c1 | c2 |
=========================================================================
2022-02-07 14:54:54.189 | 2 | beijing |
Query OK, 1 row(s) in set (0.005644s)
因为update = 2
达不到你想要的,可以用update = 1