# Copy measurment to another DB with new measurment name

**URL:** <https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459>\
**Category:** InfluxDB 1\
**Tags:** influxdb\
**Created:** [June 21, 2021, 7:38pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459 "2021-06-21T19:38:29Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [June 21, 2021, 7:38pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/1 "2021-06-21T19:38:29Z")

</div>

Hello  
i need some help to copy some measurment from a DB into another DB and into a new measurment!

influxDB 1.8x

source would be  
DB-Name db433Mhz  
measurements average

neue DB  
DB-Name spez\_temp\_day

into a new measurement temperatur  
no measurements table there now

do the measurment need to me allready in the new DB?

how to do it without bracking something.

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [June 22, 2021, 3:29pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/2 "2021-06-22T15:29:43Z")

</div>

Hello @vinc,  
You can follow this logic but instead of pushing to Influx again:

> [@Move data from Influx V1 to Influx V2](https://community.influxdata.com/t/move-data-from-influx-v1-to-influx-v2/17126/2):
>
> Hello @mirkocomparetti, Since we don’t have an easy button to do imports into our InfluxDB Cloud I wrote out some suggested paths below. Something to be aware of is the [rate limits](https://docs.influxdata.com/influxdb/cloud/account-management/pricing-plans/). 1) Dual Writing I would suggest sending the data from your clients to both the cloud instance and your existing local instance. That way you can make sure the cloud has the buckets/ data/ format/ schema/ etc. that you are wanting. It is easier to get this right at the beginning since we are schema on write. 2) Ex…

How to export to line protocol with 1.x:

> **[Using InfluxDB To Write and Export Data In Line Protocol | InfluxData](https://www.influxdata.com/blog/tldr-influxdb-tech-tips-november-3-2016/)**
>
> In this weekly post we recap the most interesting InfluxDB and TICK-stack related issues, using InfluxDB to write and export data in line protocol.

^that’s for historical data, otherwise you can apply a continuous query and copy data to a new measurement in real time.

---

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [June 22, 2021, 4:41pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/3 "2021-06-22T16:41:28Z")

</div>

hello @Anaisdg  
thanks for your feedback, i did not understand your information  
but i found to copy the db itself and then deletet the measurment not needed  
and renamed with into the measurment.  
NOW  
i also inject with node red into the DB this works  
but in the old db it was below the avarage and new it is added to temp

> select \* from temperatur ORDER BY time DESC LIMIT 10  
> name: temperatur  
> time | average | temp

* * *

1624379668272757650 | | 20.43  
1624379662286809291 | | 20.43  
1624376664853949466 | 21.17  
1624375464832759378 | 21.07  
1624374264847409586 | 21.17

so now how to move the data from average into temp?

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [June 22, 2021, 4:57pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/4 "2021-06-22T16:57:20Z")

</div>

Hello @vinc,  
You’ll have to export the data into a file and then rewrite it to a new measurement.

---

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [June 22, 2021, 5:00pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/5 "2021-06-22T17:00:30Z")

</div>

Hello @Anaisdg  
it must be something else because

> ## show MEASUREMENTS name: measurements name
> 
> Sonnenazimut  
> temperatur

i have only this two

> > select \* from temperatur ORDER BY time DESC LIMIT 10  
> > name: temperatur  
> > time average temp

* * *

so would it be possible it was taged without i know it

---

<div class="post-metadata">

**Author:** ![Pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pooh](https://community.influxdata.com/u/Pooh)\
**Post date:** [June 22, 2021, 6:09pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/6 "2021-06-22T18:09:10Z")

</div>

Did you already set up a Continuous Query?

I don’t understand the difference between:

> select \* from temperatur ORDER BY time DESC LIMIT 10
> 
> name: temperatur  
> time average temp
> 
> * * *

and:

---

<div class="post-metadata">

**Author:** ![Pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pooh](https://community.influxdata.com/u/Pooh)\
**Post date:** [June 22, 2021, 6:24pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/7 "2021-06-22T18:24:58Z")

</div>

Hm, something didn’t come out as intended there - the email → forum interface  
has obviously swallowed some of what I quoted. Try again…

Did you already set up a Continuous Query?

I don’t understand the difference between:

> select \* from temperatur ORDER BY time DESC LIMIT 10
> 
> name: temperatur  
> time average temp
> 
> * * *

and:

---

<div class="post-metadata">

**Author:** ![Pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pooh](https://community.influxdata.com/u/Pooh)\
**Post date:** [June 22, 2021, 6:55pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/8 "2021-06-22T18:55:15Z")

</div>

Okay, I’m going to try this once more.

Did you already set up a Continuous Query?

I don’t understand the difference between what you wrote at 19:10:39 CEST:

> select \* from temperatur ORDER BY time DESC LIMIT 10
> 
> name: temperatur  
> time average temp
> 
> * * *

and what you wrote previously at 18:51:30 CEST:

> select \* from temperatur ORDER BY time DESC LIMIT 10
> 
> name: temperatur  
> time | average | temp
> 
> * * *
> 
> 1624379668272757650 | | 20.43  
> 1624379662286809291 | | 20.43  
> 1624376664853949466 | 21.17  
> 1624375464832759378 | 21.07  
> 1624374264847409586 | 21.17

What changed between the two times you ran that same query?

Antony.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Luisotto](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/giovanni_luisotto/32/4017_2.png) [@Giovanni\_Luisotto](https://community.influxdata.com/u/Giovanni_Luisotto)\
**Post date:** [June 22, 2021, 6:57pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/9 "2021-06-22T18:57:17Z")

</div>

Hi @vinc

The task itself can be really easy but I need some additional info.

1. You see you are running InfluxDB 1.8x, do you want to keep the same version?
2. Do you want to move the data on a different DB in the same server or on some other server?

Now I’ll assume you are trying to move data locally, so just from a DB on the server to another DB on the same server.  
You just need to use the [INTO clause](https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/#the-into-clause), in the docs you will find several useful examples, even to move lots of data.

The query you need is as simple as

```auto
SELECT * 
INTO " __DestDDB__"." __DestRp__"." __DestMeasurementName__" 
FROM " __CurrentDB__"." __RP__"." __Measurement__" 
GROUP BY *

```

Note that the `GROUP BY *` at the end is extremely important as it will keep tags and fields as they are, without it all the data will be stored as fields.  
If you have a lot of data you might want to filter the data and load them a week at a time (or whatever suits you)

In order to make it work, you just need:

- create the destination DB
- create the desired retention policy

the measurement will be created automatically when the data are written

---

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [June 22, 2021, 7:06pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/10 "2021-06-22T19:06:49Z")

</div>

maybe it helps with the printscreen  
the measurment befor was called avarage!  
i renamed it into temperature  
and with the select \* query in the picture i take it from the new masurment temperature  
but it still keep somewhere avarag.  
the temp is the input in the last houers!

 ![influxdb1](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/154a7f6bc0c0f2efe8c6d9e02aad62bcfbaa2854.png)

i would like to move the number in avarag into temp

---

<div class="post-metadata">

**Author:** ![Giovanni\_Luisotto](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/giovanni_luisotto/32/4017_2.png) [@Giovanni\_Luisotto](https://community.influxdata.com/u/Giovanni_Luisotto)\
**Post date:** [June 22, 2021, 9:49pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/11 "2021-06-22T21:49:27Z")

</div>

That’s not a measurement name, that’s a field name and is completely different.  
you can’t rename fields, the process to “rename” them is to:

1. Copy the data to a new measurement (a temporary one), using `SELECT INTO` (you also need to rename the field using an alias)
2. Drop the original Measurement
3. Copy the data from temp back to the desired one
4. remove the temp measurement

which translates to something like this

```auto
SELECT average AS temp INTO tmpdata FROM temperature GROUP BY *
SELECT temp INTO tmpdata FROM temperature GROUP BY *

DROP MEASUREMENT temperature

SELECT temp INTO temperature FROM tmpdata GROUP BY *

DROP MEASUREMENT tmpdata

```

---

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [June 23, 2021, 8:43am UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/12 "2021-06-23T08:43:46Z")

</div>

at first it did not work time/written both 0  
then i check it i had a spelling error or just german  
changed and it worked as you wrote  
thank you very much  
is this temp a tag?  
or would it be better to have taged datas?

in the future i would like to count days above 20 25 or 30 degree and compare it with the past  
i also would check at 06:00 if the last past 12h are below 20 degree this would be a tropical night, but this magic would then be in Grafan v8

have a nice day vinc

---

<div class="post-metadata">

**Author:** ![Giovanni\_Luisotto](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/giovanni_luisotto/32/4017_2.png) [@Giovanni\_Luisotto](https://community.influxdata.com/u/Giovanni_Luisotto)\
**Post date:** [June 23, 2021, 9:23pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/13 "2021-06-23T21:23:23Z")

</div>

“temp” was a measurement, you can see it as the equivalent of a table if you are used to SQL databases.  
That said, InfluxDB works in a very different way.

I suggest you have a good look at the docs, starting from [here](https://docs.influxdata.com/influxdb/v1.8/concepts/key_concepts/), most of the common needs have already been answered here on the forum, so you shouldn’t have problems when it comes to finding answers.

About your need to track days/hours, well it does not come out of the box at least using InfluxQL, you might have some more luck with Flux, but I’m not that knowledgeable in it.  
Have a look around about days/hours once you get some solid bases about how the DB structure works and how it can be queried as that is actually the key to your needs

Have a nice day

---

<div class="post-metadata">

**Author:** ![vinc](https://avatars.discourse-cdn.com/v4/letter/v/e9c0ed/32.png) [@vinc](https://community.influxdata.com/u/vinc)\
**Post date:** [August 4, 2021, 6:12pm UTC](https://community.influxdata.com/t/copy-measurment-to-another-db-with-new-measurment-name/20459/14 "2021-08-04T18:12:59Z")

</div>

Hello @Giovanni_Luisotto

 ![influxdb2](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/1b8a4163139d8b55778ff903bce0964b302c5cdd.png)

i need your help again ;-(

how to move all the datas from average into temp\_mix  
and how to delete average colone at the end?

thanks for your help again.

have a nice day  
vinc
