INSERT

    This section mainly introduces the use of INSERT SQL statement for real-time data import in the scenario.

    The statement is used to insert data into one or more specified timeseries created. For each point of data inserted, it consists of a timestamp and a sensor acquisition value (see ).

    In the scenario of this section, take two timeseries and root.ln.wf02.wt02.hardware as an example, and their data types are BOOLEAN and TEXT, respectively.

    The sample code for single column data insertion is as follows:

    The INSERT statement can also support the insertion of multi-column data at the same time point. The sample code of inserting the values of the two timeseries at the same time point ‘2’ is as follows:

    1. IoTDB > insert into root.ln.wf02.wt02(timestamp, status, hardware) VALUES (2, false, 'v2')

    In addition, The INSERT statement support insert multi-rows at once. The sample code of inserting two rows as follows:

    After inserting the data, we can simply query the inserted data using the SELECT statement:

    In addition, we can omit the timestamp column, and the system will use the current system timestamp as the timestamp of the data point. The sample code is as follows:

      Note: Timestamps must be specified when inserting multiple rows of data in a SQL.

      Insert Data Into Aligned Timeseries

      To insert data into a group of aligned time series, we only need to add the ALIGNED keyword in SQL, and others are similar.

      The sample code is as follows:

      1. +-----------------------------+--------------+--------------+
      2. | Time|root.sg1.d2.s1|root.sg1.d2.s2|
      3. |1970-01-01T08:00:00.001+08:00| 1| 1.0|
      4. |1970-01-01T08:00:00.003+08:00| 3| 3.0|
      5. +-----------------------------+--------------+--------------+
      6. It costs 0.004s