简体   繁体   English

如何删除InfluxDB中除最后一条记录外的所有测量记录?

[英]How to delete all records in measurement except last record in InfluxDB?

I searched for answer all day and found influxdb hasn't '''IN''' like SQL.我一整天都在寻找答案,发现 influxdb 没有像 SQL 那样 '''IN''' 。 so can influxdb do like所以可以 influxdb 做喜欢

DELETE  
FROM tablename 
WHERE column1 NOT IN (SELECT column1 FROM tablename order by column1 desc LIMIT 1 OFFSET 0)

I have no idea.我不知道。

Everything possible with InfluxQL is specified here . 此处指定了 InfluxQL 的所有可能。 InfluxQL does not support IN operator currently. InfluxQL 目前不支持 IN 运算符。

This is one of the approaches may help you to solve your issue:这是可以帮助您解决问题的方法之一:

  • Copy the latest record to a file将最新记录复制到文件中
  • Delete records from measurement从测量中删除记录
  • Insert back to the measurement from the saved file从保存的文件中插入回测量

EDIT编辑

As @Nikolay Manolov mentioned in comment, you can find the timestamp of latest record and delete everything that is older than that.正如@Nikolay Manolov在评论中提到的,您可以找到最新记录的时间戳并删除所有比该记录更旧的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM