PostgreSQL:合并2个类似的数据库 [英] Postgresql : Merge 2 similar databases
问题描述
我需要将两个数据库(Database1& Database2)合并到Postgresql中的公共数据库。
Database1
表1
Id p> 1 - a
2 - aa
3 - aaa
4 - aaaa
Database2
Table1
Id值(Id为主键)
2 - bb
5 - bbbbb
我想输出为
OutPutDatabase
Table1
strong> Id值(ID为主键)
1 - a
2 - bb
3 - aaa
4 - aaaa
5 - bbbbb
如何实现?
不是我的想法,而是我过去阅读的一个。
pg_dump -d db1 -t table1 | psql db2
then psql and do
insert into table2(select * from table1);
I have a requirement of merging two databases (Database1 & Database2) to a common database in Postgresql.
Database1
Table1
Id - Value (Id is Primary key)
1 - a
2 - aa
3 - aaa
4 - aaaa
Database2
Table1
Id Value (Id is Primary key)
2 - bb
5 - bbbbb
I want my output as
OutPutDatabase
Table1
Id Value (Id is Primary key)
1 - a
2 - bb
3 - aaa
4 - aaaa
5 - bbbbb
How can I achieve this?
Not my idea, but one I have read in the past.
The source: Move table to new database
pg_dump -d db1 -t table1 |psql db2
then psql and do
insert into table2 (select * from table1);
这篇关于PostgreSQL:合并2个类似的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!