【问题标题】:Can I make QuestDB to add column data to existing rows?我可以让 QuestDB 将列数据添加到现有行吗?
【发布时间】:2026-01-01 22:00:01
【问题描述】:

我使用 QuestDB 并从 ILP 消息中填充数据。当标签匹配时,我想查看来自同一行不同传感器的数据。比如我先发

sensors,location=ny temperature=22 1465839830100400200

自动创建表sensors,然后使用符号列location 和双temperature。一段时间后,我可以收到另一条消息,例如

sensors,location=ny humidity=35.2 1465839830100400200

如果我什么都不做,humidity 字段将被忽略。如果我手动将湿度字段添加到表格中

alter table sensors add column humidity double

在发送第二条消息之前,我仍然返回 2 行,其中一行有温度和空湿度,另一行有湿度和空温度

| timestamp  | location | temperature | humidty |
| ---------- | -------- | ----------- | ------- |
| 2016-06-13 | ny       |        22.0 |         |
| 2016-06-13 | ny       |             |    35.2 |

如何让温度和湿度在单独发送的情况下达到同一行?

【问题讨论】:

    标签: questdb


    【解决方案1】:

    这可能不是最高效的,但很简单:

    SELECT timestamp, location, max(temperature), max(humidity) from sensors;
    

    【讨论】: