Database is similar to the database in the relational database, which is a collection of structured time series data.
Create a database named root.ln with the following syntax:
CREATE DATABASE root.ln
View all databases:
SHOW DATABASES
Drop the database named root.ln:
DELETE DATABASE root.ln
COUNT DATABASES
Time series is a collection of data points indexed by time. In IoTDB, time series refers to a complete sequence of measurement points. This section mainly introduces the management of time series.
The encoding method and data type need to be specified. For example, create a time series named root.ln.wf01.wt01.temperature:
CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH datatype=FLOAT,ENCODING=RLE
View all time series:
SHOW TIMESERIES
Use wildcards to match time series under database root.ln:
SHOW TIMESERIES root.ln.**
Delete a time series named root.ln.wf01.wt01.temperature:
DELETE TIMESERIES root.ln.wf01.wt01.temperature
Count the total number of time series:
COUNT TIMESERIES root.**
Count the number of time series under a wildcard path:
COUNT TIMESERIES root.ln.**
In addition to the concept of time series, IoTDB also has the concepts of subpaths and devices.
Subpath: It is a part of the path in a complete time series name. For example, if the time series name is root.ln.wf01.wt01.temperature, then root.ln, root.ln.wf01, and root.ln.wf01.wt01 are all its subpaths.
Device: It is a combination of a group of time series. In IoTDB, the device is a subpath from the root to the penultimate node. If the time series name is root.ln.wf01.wt01.temperature, then root.ln.wf01.wt01 is its device.
SHOW DEVICES
Check out the next level of root.ln:
SHOW CHILD PATHS root.ln
SHOW CHILD NODES root.ln
Count the number of devices:
COUNT DEVICES
Count the number of nodes at the specified level in the path:
COUNT NODES root.ln.** LEVEL=2
The following are commonly used query statements in IoTDB.
Query all time series data under the device root.ln.wf01.wt01:
SELECT * FROM root.ln.wf01.wt01
Query the data in the time series root.ln.wf01.wt01.temperature whose timestamp is greater than 2022-01-01T00:05:00.000:
SELECT temperature FROM root.ln.wf01.wt01 WHERE time > 2022-01-01T00:05:00.000
Query the data whose value is greater than 36.5 in the time series root.ln.wf01.wt01.temperature:
SELECT temperature FROM root.ln.wf01.wt01 WHERE temperature > 36.5
SELECT last * FROM root.ln.wf01.wt01