Migrate data from MySQL to PostgreSQL

卫俊誉
2023-12-01

1. Create table with new in PostgreSQL for they have different data type. Say, boolean, integer, etc.


2. Export data from MySQL

$mysqldump -u root -p -c db_name table_name >table_name.sql


3. Remove drop/create table sentence from table_name.sql

$vi table_name.sql


4. Remove quotes in table_name.sql

$sed 's/\"//g' table_name.sql > table_name1.sql


5. Replace boolean data type

$sed "s/,0,0,/,'f','f',/g" table_name1.sql > table_name2.sql


6. Import data from sql data

$psql db_name< table_name2.sql

 类似资料:

相关阅读

相关文章

相关问答