QuickStart Only SQL
3/26/26About 1 min
QuickStart Only SQL
Before executing the following SQL statements, please ensure
- IoTDB service has been successfully started
- Connected to IoTDB via Cli client
Note: If your terminal does not support multi-line pasting (e.g., Windows CMD), please adjust the SQL statements to single-line format before execution.
1. Database Management
-- Create database;
CREATE DATABASE root.ln;
-- View database;
SHOW DATABASES root.**;
-- Delete database;
DELETE DATABASE root.ln;
-- Count database;
COUNT DATABASES root.**;For detailed syntax description, please refer to: Database Management
2. Time Series Management
-- Create time series;
CREATE TIMESERIES root.ln.wf01.wt01.status BOOLEAN;
CREATE TIMESERIES root.ln.wf01.wt01.temperature FLOAT;
-- Create aligned time series;
CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT, longitude FLOAT);
-- Delete time series;
DELETE TIMESERIES root.ln.wf01.wt01.status;
-- View time series;
SHOW TIMESERIES root.ln.**;
-- Count time series;
COUNT TIMESERIES root.ln.**;For detailed syntax description, please refer to: Time Series Management
3. Data Writing
-- Single column writing;
INSERT INTO root.ln.wf01.wt01(timestamp, temperature) VALUES(1, 23.0),(2, 42.6);
-- Multi-column writing;
INSERT INTO root.ln.wf01.wt01(timestamp, status, temperature) VALUES (3, false, 33.1),(4, true, 24.6);For detailed syntax description, please refer to: Data Writing
4. Data Query
-- Time filter query;
SELECT * from root.ln.** where time > 1;
-- Value filter query;
SELECT temperature FROM root.ln.wf01.wt01 where temperature > 36.5;
-- Function query;
SELECT count(temperature) FROM root.ln.wf01.wt01;
-- Latest point query;
SELECT LAST status FROM root.ln.wf01.wt01;For detailed syntax description, please refer to: Data Query
5. Data Deletion
-- Single column deletion;
DELETE FROM root.ln.wf01.wt01.status WHERE time >= 20;
-- Multi-column deletion;
DELETE FROM root.ln.wf01.wt01.* where time <= 10;For detailed syntax description, please refer to: Data Deletion
