This topic describes how to use the INSERT syntax. It also includes the notes on the usage of the syntax.

You can query data from a Logstore and use the INSERT syntax to write the retrieved data to another Logstore. The source and destination Logstores belong to the same project. The following example shows a sample query statement that uses the INSERT syntax.

* | insert into target_logstore(k1,k2,v) select k1,k2,count(1) from source_logstore group by k1,k2
Note
  • You must create indexes for the data in the destination Logstore. Otherwise, data cannot be written to the destination Logstore. For example, you can create indexes in the destination Logstore for the k1, k2, and v fields and enable analytics for the fields.
  • You must specify the names of the fields that you want to write to the destination Logstore in the INSERT clause. For example, the syntax insert into target logstore select... is invalid.
  • If you need to convert the type of the data that is written to the destination Logstore, use a type conversion function in the SELECT clause. For more information about type conversion functions, see Type conversion functions.
  • The source and destination Logstores cannot be the same. For example, the syntax insert into logstore1 select * from logstore1 is invalid.
  • You can write a maximum of 10,000 log entries to the destination Logstore.
  • The source and destination Logstores must reside in China regions.