Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename MEASUREMENT

Tags:

influxdb

I am using influxDB instead of MySQL for time series analysis. In my database data, I have a series which is called /HFT/Data_HFT/OrderBook/DCIX_OB. That name is irrelevant and it was created by error. That series has 89 million lines, so it would be very long to recreate that series.

So this is not a solution for me:

SELECT * INTO new_name FROM old_name
DROP MEASUREMENT old_name

I tried that solution, but it didn't work at all. Here is the error :

> RENAME MEASUREMENTS 'OLD_NAME' to 'NEW_NAME'
ERR: error parsing query: found RENAME, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

How could I rename it?

like image 409
Jeremie Avatar asked May 13 '18 18:05

Jeremie


1 Answers

There is no official way to rename a measurement yet. The way to do it is:

  1. Find all tags in your measurement using SHOW TAG KEYS FROM MyMeasurement. Let's assume your tags were tag1 and tag2
  2. Copy all data into a new measurement using SELECT * INTO MyMeasurementCopy from MyMeasurement GROUP BY tag1,tag2
  3. Once you are 100% sure all data is copied, you can drop the old data using DROP MEASUREMENT MyMeasurement

It's a long process but it works.

like image 56
Sarang Avatar answered Nov 03 '22 15:11

Sarang