赞
踩
本博文主要讲述数据库管理和数据读写
CREATE DATABASE root.ln
IoTDB> CREATE DATABASE root.test
Msg: The statement is executed successfully.
注意:必须是root.开头
这一点也是我一直吐槽的地方,为啥要限制必须root.
开头呢?
全部都是root.
开头不就等于全部都没有root.
开头。意义何在呢。
IoTDB> CREATE DATABASE test
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 700: Error occurred while parsing SQL to physical plan: line 1:16 mismatched input 'test' expecting ROOT
IoTDB> CREATE DATABASE test.test
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 700: Error occurred while parsing SQL to physical plan: line 1:16 mismatched input 'test' expecting ROOT
注意:Database的父子节点都不能再设置 database
IoTDB> CREATE DATABASE root.test.aa
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 501: root.test has already been created as database
IoTDB> CREATE DATABASE root.test1.aa
Msg: The statement is executed successfully.
SHOW DATABASES;
IoTDB> SHOW DATABASES;
+----------------+----+-----------------------+---------------------+---------------------+
| Database| TTL|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+----------------+----+-----------------------+---------------------+---------------------+
| root.user1|null| 1| 1| 604800000|
| root.test1.aa|null| 1| 1| 604800000|
| root.test|null| 1| 1| 604800000|
|root.water_meter|null| 1| 1| 604800000|
+----------------+----+-----------------------+---------------------+---------------------+
Total line number = 4
It costs 0.010s
DELETE DATABASE root.ln
IoTDB> DELETE DATABASE root.user1
Msg: The statement is executed successfully.
IoTDB> SHOW DATABASES;
+----------------+----+-----------------------+---------------------+---------------------+
| Database| TTL|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+----------------+----+-----------------------+---------------------+---------------------+
| root.test1.aa|null| 1| 1| 604800000|
| root.test|null| 1| 1| 604800000|
|root.water_meter|null| 1| 1| 604800000|
+----------------+----+-----------------------+---------------------+---------------------+
Total line number = 3
It costs 0.006s
IoTDB> DELETE DATABASE root.test1.aa
Msg: The statement is executed successfully.
IoTDB> SHOW DATABASES;
+----------------+----+-----------------------+---------------------+---------------------+
| Database| TTL|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+----------------+----+-----------------------+---------------------+---------------------+
| root.test|null| 1| 1| 604800000|
|root.water_meter|null| 1| 1| 604800000|
+----------------+----+-----------------------+---------------------+---------------------+
Total line number = 2
It costs 0.005s
select status from root.test.test
IoTDB> select status from root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|2024-05-03T19:18:07.573+08:00| 1.0|
|2024-05-03T19:18:19.825+08:00| 2.0|
|2024-05-03T19:18:21.893+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 3
It costs 0.127s
INSERT INTO root.test.test(status) values(1)
IoTDB> INSERT INTO root.test.test(status) values(1)
Msg: The statement is executed successfully.
IoTDB> INSERT INTO root.test.test(status) values(2)
Msg: The statement is executed successfully.
IoTDB> INSERT INTO root.test.test(status) values(3)
Msg: The statement is executed successfully.
IoTDB> select status from root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|2024-05-03T19:18:07.573+08:00| 1.0|
|2024-05-03T19:18:19.825+08:00| 2.0|
|2024-05-03T19:18:21.893+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 3
It costs 0.127s
注意:新增多条数据,需要传入时间戳参数
INSERT INTO root.test.test(timestamp,status) values(1,4),(2,5),(3,6)
IoTDB> INSERT INTO root.test.test(timestamp,status) values(1,4),(2,5),(3,6)
Msg: The statement is executed successfully.
IoTDB> select status from root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|1970-01-01T08:00:00.001+08:00| 4.0|
|1970-01-01T08:00:00.002+08:00| 5.0|
|1970-01-01T08:00:00.003+08:00| 6.0|
|2024-05-03T19:18:07.573+08:00| 1.0|
|2024-05-03T19:18:19.825+08:00| 2.0|
|2024-05-03T19:18:21.893+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 6
It costs 0.012s
传入同样的时间戳,即可覆盖该时间戳的上一条数据
IoTDB> INSERT INTO root.test.test(timestamp,status) values(1,444)
Msg: The statement is executed successfully.
IoTDB> SELECT status FROM root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|1970-01-01T08:00:00.001+08:00| 444.0|
|1970-01-01T08:00:00.002+08:00| 5.0|
|1970-01-01T08:00:00.003+08:00| 6.0|
|2024-05-03T19:18:07.573+08:00| 1.0|
|2024-05-03T19:18:19.825+08:00| 2.0|
|2024-05-03T19:18:21.893+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 6
It costs 0.010s
DELETE FROM root.test.test.status where time < 4
IoTDB> DELETE FROM root.test.test.status where time < 4
Msg: The statement is executed successfully.
IoTDB> SELECT status FROM root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|2024-05-03T19:18:07.573+08:00| 1.0|
|2024-05-03T19:18:19.825+08:00| 2.0|
|2024-05-03T19:18:21.893+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 3
It costs 0.014s
觉得好,就一键三连呗(点赞+收藏+关注)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。