DML
Is used to manipulate data stored in a database.
INSERT
tip
CnosDB requires the inserted data columns to have a timestamp and the VALUES
list must be constant. If a column is not selected, the value is NULL
.
The time column cannot be NULL
, TAG
column and FIELD
column can be NULL
.
For example, INSERT INTO air (TIME, station, visibility) VALUES(1666132800000000000, NULL, NULL)
If the VALUES
list needs an expression, use the INSERT SELECT
syntax.
INSERT [INTO] tb_name [ ( column_name [, ...] ) ] VALUES ( const [, ...] ) [, ...] | select_statment;
View the INSERT
example
Insert a record.
INSERT INTO air (TIME, station, visibility, temperature, pressure) VALUES(now(), 'XiaoMaiDao', 56, 69, 77);
Insert multiple records.
INSERT INTO air (TIME, station, visibility, temperature, pressure) VALUES
('2022-10-19 05:40:00', 'XiaoMaiDao', 55, 68, 76),
('2022-10-19 04:40:00', 'XiaoMaiDao', 55, 68, 76);
Insert records based on query results.
- Create a new table.
CREATE TABLE air_visibility (
visibility DOUBLE,
TAGS(station)
);
- Insert records into
air_visibility
based on query results.
INSERT air_visibility (TIME, station, visibility) SELECT TIME, station, visibility FROM air;