MySQL Forums
Forum List  »  MySQL HeatWave

Re: How to import data from PostgreSQL to MySQL HeatWave Database Service
Posted by: Ahsan Mehmood
Date: September 30, 2023 12:40AM

To import data from PostgreSQL to MySQL HeatWave Database Service, you can follow these steps:

Export your PostgreSQL data to a CSV file. You can use the pg_dump command to do this. For example, to export all tables from the my_database database to a CSV file called my_data.csv, you would run the following command:
pg_dump -Fc my_database > my_data.csv
Create a MySQL HeatWave database and tables to match the structure of your PostgreSQL data. You can use the following MySQL Shell commands to do this:
Code snippet
CREATE DATABASE my_database;
USE my_database;

CREATE TABLE my_table (
column1 INT,
column2 VARCHAR(255),
column3 DATETIME
);
Use code with caution. Learn more
Import your CSV data into the MySQL HeatWave tables. You can use the following MySQL Shell commands to do this:
Code snippet
LOAD DATA INFILE 'my_data.csv' INTO TABLE my_table;
Use code with caution. Learn more
Verify that the data was imported correctly. You can use the following MySQL Shell commands to do this:
Code snippet
SELECT * FROM my_table;
Use code with caution. Learn more
You may need to modify the table definitions in step 2 to make them compatible with MySQL HeatWave. For example, you may need to change the data types of some columns. You can use the following table to help you with the data type mapping:

| PostgreSQL data type | MySQL HeatWave data type |
|---|---|---|
| INT | INT |
| VARCHAR(n) | VARCHAR(n) |
| DATE | DATE |
| TIMESTAMP | DATETIME |

You may also need to use a tool to convert your CSV data to a format that is compatible with MySQL HeatWave. For example, you can use the pg2mysql tool to convert a PostgreSQL dump file to a MySQL dump file.

Once you have imported your data into MySQL HeatWave, you can start using it in your applications.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to import data from PostgreSQL to MySQL HeatWave Database Service
September 30, 2023 12:40AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.