General SQL Statements
Database Management
Database is similar to the database in the relational database, which is a collection of structured time series data.
create database
Create a database named root.ln with the following syntax:
1. CREATE DATABASE root.ln
show databases
View all databases:
1. SHOW DATABASES
delete database
Drop the database named root.ln:
1. DELETE DATABASE root.ln
count databases
1. COUNT DATABASES
Time Series Management
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.
create timeseries
The encoding method and data type need to be specified. For example, create a time series named root.ln.wf01.wt01.temperature:
1. CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH datatype=FLOAT,ENCODING=RLE
show timeseries
View all time series:
1. SHOW TIMESERIES
Use wildcards to match time series under database root.ln:
1. SHOW TIMESERIES root.ln.**
delete timeseries
Delete a time series named root.ln.wf01.wt01.temperature:
1. DELETE TIMESERIES root.ln.wf01.wt01.temperature
count timeseries
Count the total number of time series:
1. COUNT TIMESERIES root.**
Count the number of time series under a wildcard path:
1. COUNT TIMESERIES root.ln.**
Time Series Path Management
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
1. SHOW DEVICES
show child paths
Check out the next level of root.ln:
1. SHOW CHILD PATHS root.ln
show child nodes
1. SHOW CHILD NODES root.ln
count devices
Count the number of devices:
1. COUNT DEVICES
count nodes
Count the number of nodes at the specified level in the path:
1. COUNT NODES root.ln.** LEVEL=2
Query Data
The following are commonly used query statements in IoTDB.
Query the data of the specified time series
Query all time series data under the device root.ln.wf01.wt01:
1. SELECT * FROM root.ln.wf01.wt01
Query time series data within a certain time range
Query the data in the time series root.ln.wf01.wt01.temperature whose timestamp is greater than 2022-01-01T00:05:00.000:
1. SELECT temperature FROM root.ln.wf01.wt01 WHERE time > 2022-01-01T00:05:00.000
Query time series data whose values are within the specified range
Query the data whose value is greater than 36.5 in the time series root.ln.wf01.wt01.temperature:
1. SELECT temperature FROM root.ln.wf01.wt01 WHERE temperature > 36.5
Use last to query the latest point data
1. SELECT last * FROM root.ln.wf01.wt01
