7

I have my_db1, my_db2, my_db3 in Influxdb, now is there a way to move or copy data between these databases with a query?

gitvegas
  • 101
  • 1
  • 2
  • 4

1 Answers1

20

InfluxQL provides an INTO clause that can be used to copy data between databases.

For example, if I had the point cpu,host=server1 value=100 123 in db_1 and wanted to copy that data to the point new_cpu,host=server1 value=100 123 in db_2. I could issue the following query:

SELECT * INTO db_2..new_cpu FROM db_1..cpu group by *

For more information, see the documentation

Michael Desa
  • 4,607
  • 24
  • 19
  • 8
    For any future reader, the reason for having that group by is this: If you use `SELECT *` with `INTO`, the query converts tags in the current measurement to fields in the new measurement. This can cause InfluxDB to overwrite points that were previously differentiated by a tag value. Use `GROUP BY ` to preserve tags as tags. – Gediminas Mar 24 '20 at 15:51