键值对

键值对的键和值可以被定义为标识符或者常量。

下面将介绍键值对的使用场景。

  • 触发器中表示触发器属性的键值对。参考示例语句中 WITH 后的属性键值对。
1. # 以字符串形式表示键值对
2. CREATE TRIGGER `alert-listener-sg1d1s1`
3. AFTER INSERT
4. ON root.sg1.d1.s1
5. AS 'org.apache.iotdb.db.engine.trigger.example.AlertListener'
6. WITH (
7. 'lo' = '0',
8. 'hi' = '100.0'
9. )

11. # 以标识符和常量形式表示键值对
12. CREATE TRIGGER `alert-listener-sg1d1s1`
13. AFTER INSERT
14. ON root.sg1.d1.s1
15. AS 'org.apache.iotdb.db.engine.trigger.example.AlertListener'
16. WITH (
17. lo = 0,
18. hi = 100.0
19. )
  • 时间序列中用于表示标签和属性的键值对。
1. # 创建时间序列时设定标签和属性,用字符串来表示键值对。
2. CREATE timeseries root.turbine.d1.s1(temprature)
3. WITH datatype = FLOAT, encoding = RLE, compression = SNAPPY, 'max_point_number' = '5'
4. TAGS('tag1' = 'v1', 'tag2'= 'v2') ATTRIBUTES('attr1' = 'v1', 'attr2' = 'v2')

6. # 创建时间序列时设定标签和属性,用标识符和常量来表示键值对。
7. CREATE timeseries root.turbine.d1.s1(temprature)
8. WITH datatype = FLOAT, encoding = RLE, compression = SNAPPY, max_point_number = 5
9. TAGS(tag1 = v1, tag2 = v2) ATTRIBUTES(attr1 = v1, attr2 = v2)
1. # 修改时间序列的标签和属性
2. ALTER timeseries root.turbine.d1.s1 SET 'newTag1' = 'newV1', 'attr1' = 'newV1'

4. ALTER timeseries root.turbine.d1.s1 SET newTag1 = newV1, attr1 = newV1
1. # 修改标签名
2. ALTER timeseries root.turbine.d1.s1 RENAME 'tag1' TO 'newTag1'

4. ALTER timeseries root.turbine.d1.s1 RENAME tag1 TO newTag1
1. # 插入别名、标签、属性
2. ALTER timeseries root.turbine.d1.s1 UPSERT
3. ALIAS='newAlias' TAGS('tag2' = 'newV2', 'tag3' = 'v3') ATTRIBUTES('attr3' ='v3', 'attr4'='v4')

5. ALTER timeseries root.turbine.d1.s1 UPSERT
6. ALIAS = newAlias TAGS(tag2 = newV2, tag3 = v3) ATTRIBUTES(attr3 = v3, attr4 = v4)
1. # 添加新的标签
2. ALTER timeseries root.turbine.d1.s1 ADD TAGS 'tag3' = 'v3', 'tag4' = 'v4'

4. ALTER timeseries root.turbine.d1.s1 ADD TAGS tag3 = v3, tag4 = v4
1. # 添加新的属性
2. ALTER timeseries root.turbine.d1.s1 ADD ATTRIBUTES 'attr3' = 'v3', 'attr4' = 'v4'

4. ALTER timeseries root.turbine.d1.s1 ADD ATTRIBUTES attr3 = v3, attr4 = v4
1. # 查询符合条件的时间序列信息
2. SHOW timeseries root.ln.** WHRER 'unit' = 'c'

4. SHOW timeseries root.ln.** WHRER unit = c
  • 创建 Pipe 以及 PipeSink 时表示属性的键值对。
1. # 创建 PipeSink 时表示属性
2. CREATE PIPESINK my_iotdb AS IoTDB ('ip' = '输入你的IP')

4. # 创建 Pipe 时在 WITH 子句中表示属性
5. CREATE PIPE my_pipe TO my_iotdb FROM
6. (select ** from root WHERE time>=yyyy-mm-dd HH:MM:SS) WITH 'SyncDelOp' = 'true'