简体   繁体   English

如何将数据从一个 PostgreSQL 数据库迁移到另一个(表/列名略有不同)?

[英]How can I migrate data from one PostgreSQL database to another (with slightly different table/column names)?

I am trying to migrate a large portion of one postgres database to another postgres database that has a slightly different layout/table names/column names.我正在尝试将一个 postgres 数据库的大部分迁移到另一个布局/表名/列名略有不同的 postgres 数据库。 But the data is the same.但是数据是一样的。 What is a good way to do this?有什么好方法可以做到这一点? All I can think of is using pg_dump and then manually changing the column names and table names in the dump file but there is a lot of data to work through and that way would also be very error prone.我能想到的只是使用 pg_dump,然后手动更改转储文件中的列名和表名,但是有很多数据需要处理,这样也很容易出错。

Use dblink to add data to new tables in the new database.使用 dblink 将数据添加到新数据库中的新表中。

Example:例子:

INSERT into new_table ( cd_ace, no_desc )
SELECT cd_accessory, no_description
FROM DBLINK('host=ip_address_remote port=5470 dbname=database_name user=user password=password ',
'SELECT cd_acessorio, no_description from dbatez.acessorio')
  AS a ( cd_accessory character varying(4), no_description character varying(40));

I hope I helped you.我希望我对你有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从一个表复制到另一个不同的列名 - Copying data from one table to another different column names PostgreSQL:如何将数据从一个数据库表复制到另一个数据库 - PostgreSQL: How to copy data from one database table to another database 如何将数据从一列插入另一张表中的另一列 - How to insert data from one column into another column in a different table 我可以迁移一个表而不影响数据库中的数据吗? - Can i migrate one table without affecting my data in the database? 如何将带有数据的表列从一个数据库复制到另一个数据库? - How I can copy a table columns with data from one database to another database? 我们如何在 mysql 中的另一个表中查找一个表的列名 - How can we lookup column names of one table with data in another table in mysql 如何在不更改其中数据的情况下将表的模式从一个数据库导入到另一个数据库中的现有表? - How can i import a schema of a table from one database to an existing table in another without altering the data in it? 将一个数据库表的值迁移到另一个具有不同列的表中 - Migrate values of one database table into another table with different columns 在MSSQL中将数据从一个数据库表迁移到另一台服务器上的另一个表 - Migrate data from one database table to another one on another server in MSSQL 如何在postgresql中将数据从一个数据库复制到另一个数据库? - how to copy data from one database to another database in postgresql?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM