Aan
Aan

Reputation: 12910

Bind records of two databases

I have two Windows machines; each machine has a .NET C# application used to insert data to PostgreSQL data base tables. Both machines have the same exact 4 tables which are: Binfiles , gendata, leave and training.

But each machine has different inserted records. I want to merge the inserted data to be in one machine only. What is the best practice and easiest way to do that?

Upvotes: 0

Views: 83

Answers (1)

Scotch
Scotch

Reputation: 3226

From one of your machines tables

 COPY binfiles TO '/tmp/binfiles.csv' DELIMITER ',' CSV HEADER;
 COPY gendata TO '/tmp/gendata.csv' DELIMITER ',' CSV HEADER;
 COPY leave TO '/tmp/leave.csv' DELIMITER ',' CSV HEADER;
 COPY training TO '/tmp/gendata.csv' DELIMITER ',' CSV HEADER;

then on your other machine you copy from

 COPY binfiles FROM '/tmp/binfiles.csv' DELIMITERS ',' CSV;

and so forth. or you could do it in SQL, but you would first need to have both sets of tables insert into newBin select * from oldbin

Upvotes: 1

Related Questions