本文将介绍关于IoTDB使用的基本流程,如果需要更多信息,请浏览我们官网的指引。
> sbin/start-server.sh
Windows系统启动命令如下:
> sbin\start-server.bat
> sbin/start-client.sh -h 127.0.0.1 -p 6667 -u root -pw root
Windows系统启动命令如下:
> sbin\start-client.bat -h 127.0.0.1 -p 6667 -u root -pw root
启动后出现如图提示即为启动成功。
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version x.x.x
IoTDB> login successfully
IoTDB>
IoTDB> SET STORAGE GROUP TO root
可以通过 SHOW STORAGE GROUP 关键字查看当前IOTDB的存储组
IoTDB> SHOW STORAGE GROUP
执行结果如下
+-----------------------------------+
| Storage Group|
+-----------------------------------+
| root|
+-----------------------------------+
storage group number = 1
IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status(你的时间序列名称) WITH DATATYPE=BOOLEAN(数据类型), ENCODING=PLAIN(编码)
IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
IoTDB> SHOW TIMESERIES
执行结果为:
+-------------------------------+---------------+--------+--------+
| Timeseries| Storage Group|DataType|Encoding|
+-------------------------------+---------------+--------+--------+
| root.ln.wf01.wt01.status| root| BOOLEAN| PLAIN|
| root.ln.wf01.wt01.temperature| root| FLOAT| RLE|
+-------------------------------+---------------+--------+--------+
Total timeseries number = 2
IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status(时间序列名称)
执行结果为:
+------------------------------+--------------+--------+--------+
| Timeseries| Storage Group|DataType|Encoding|
+------------------------------+--------------+--------+--------+
| root.ln.wf01.wt01.status| root| BOOLEAN| PLAIN|
+------------------------------+--------------+--------+--------+
Total timeseries number = 1
IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
insert into (时间序列名称)(字段名,创建时间序列的时候设置的字段名) values (属性)
IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
- IoTDB> SELECT status FROM root.ln.wf01.wt01
查询结果如下:
+-----------------------+------------------------+
| Time|root.ln.wf01.wt01.status|
+-----------------------+------------------------+
|1970-01-01T08:00:00.100| true|
|1970-01-01T08:00:00.200| false|
+-----------------------+------------------------+
Total line number = 2
我们也可以查询多个时间序列的数据结果,SQL语句如下:
IoTDB> SELECT * FROM root.ln.wf01.wt01
查询结果如下:
+-----------------------+--------------------------+-----------------------------+
| Time| root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
+-----------------------+--------------------------+-----------------------------+
|1970-01-01T08:00:00.100| true| null|
|1970-01-01T08:00:00.200| false| 20.71|
+-----------------------+--------------------------+-----------------------------+
Total line number = 2
IoTDB> quit 或 IoTDB> exit
> $sbin/stop-server.sh
> $sbin\stop-server.bat
本文转载IOTDB官方文档