SOLVED:
Finally I got it! I got merge there databases with different schemas in one.
First create the new DB, then using right the “AS” clause to change the name of columns and “INTO” to copy data to the new database
The “secret” for a newby user is:
SELECT "old_data_name" AS "new_data_name" INTO "New_database"."Retention_Policy"."Measurement" FROM "old_DB_measurement_name" WHERE time >= '2019-06-19T21:00:00Z' AND time <= '2020-02-06T03:00:30Z' GROUP BY *;
"GROUP BY * " means copy all tags.
First os all, we create the new database:
CREATE DATABASE New_DB_v2
First database: (The oldest database. Look after WHERE, I used a filter (“P_Grid” < 0) to copy only some data)
use fotovoltaica
SELECT "P_PV" AS "P_FV" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2019-06-19T21:00:00Z' AND time <= '2020-02-06T03:00:30Z' GROUP BY *;
SELECT "P_Grid" AS "P_Exp" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE ("P_Grid" < 0) AND time >= '2019-06-19T21:00:00Z' AND time <= '2020-02-06T03:00:30Z' GROUP BY *;
SELECT "P_Grid" AS "P_Red" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE ("P_Grid" >= 0) AND time >= '2019-06-19T21:00:00Z' AND time <= '2020-02-06T03:00:30Z' GROUP BY *;
SELECT "P_Load" AS "P_Cargas" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2019-06-19T21:00:00Z' AND time <= '2020-02-06T03:00:30Z' GROUP BY *;
Second database: (here change the data names and have different old measurement name)
use fotovoltaica_pruebas2
SELECT "P_FV" AS "P_FV" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2020-02-06T03:00:31Z' AND time <= '2020-03-01T22:11:20Z' GROUP BY *;
SELECT "P_Export" AS "P_Exp" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2020-02-06T03:00:31Z' AND time <= '2020-03-01T22:11:20Z' GROUP BY *;
SELECT "P_Red" AS "P_Red" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2020-02-06T03:00:31Z' AND time <= '2020-03-01T22:11:20Z' GROUP BY *;
SELECT "P_Cargas" AS "P_Cargas" INTO "New_DB_v2"."autogen"."Potencias" FROM "Medida_Fronius" WHERE time >= '2020-02-06T03:00:31Z' AND time <= '2020-03-01T22:11:20Z' GROUP BY *;
Third database: (here the name of measurements are the same “Potencias”, but it is in differents databases)
use fotovoltaica_v2
SELECT "P_FV" AS "P_FV" INTO "New_DB_v2"."autogen"."Potencias" FROM "Potencias" WHERE time >= '2020-03-01T22:11:21Z' AND time <= now() GROUP BY *;
SELECT "P_Expo" AS "P_Exp" INTO "New_DB_v2"."autogen"."Potencias" FROM "Potencias" WHERE time >= '2020-03-01T22:11:21Z' AND time <= now() GROUP BY *;
SELECT "P_Red" AS "P_Red" INTO "New_DB_v2"."autogen"."Potencias" FROM "Potencias" WHERE time >= '2020-03-01T22:11:21Z' AND time <= now() GROUP BY *;
SELECT "P_Cargas" AS "P_Cargas" INTO "New_DB_v2"."autogen"."Potencias" FROM "Potencias" WHERE time >= '2020-03-01T22:11:21Z' AND time <= now() GROUP BY *;
I hope these examples could help new users and that it helps developers to add better examples in the documentation.