sway
sway

Reputation: 373

How can I combine multiple Postgres database dumps into a single database?

I have ~100 Postgres .dump from different sources. They all have the same schema, just a single table, and a few hundred to a few hundred thousand rows. However, the data was collected at different locations and now needs to all be combined.

So I'd like to merge all the rows from all the databases into one single database, ignoring the ID key. What would be a decent way to do this? I may collect more data in the future from more sources, so it's likely to be a process I need to repeat.

Upvotes: 0

Views: 1297

Answers (1)

Jasen
Jasen

Reputation: 12412

if needed use pg_restore to convert the dumps into SQL.

run the SQL dump trhough

 sed '/^COPY .* FROM stdin;$/,/^\\.$/ p;d'

as there is only one table in your data that will give you the copy command needed to load the data send that to your database to load the data.

Upvotes: 1

Related Questions