开发者

updating remote tables in postgresql (keeping fks)

开发者 https://www.devze.com 2023-02-12 20:24 出处:网络
I am using pgAdmin III at my work and postgresql at work and at the remote hosting server (webfaction). Through Putty I am creating a tunnel for pgAdmin t开发者_如何转开发o work with my local and my r

I am using pgAdmin III at my work and postgresql at work and at the remote hosting server (webfaction). Through Putty I am creating a tunnel for pgAdmin t开发者_如何转开发o work with my local and my remote databases. I have a table which primary key is referenced by other tables' keys (as a foreign key).

What is the best way to update that remote table with the values I have on my local table?

What I (unsuccessfully) try to do is 'backup' my local table and then try to 'restore' my remote table with that file. However, pgAdmin III gives me duplicate key value error.

pg_restore: connecting to database for restore
pg_restore: restoring data for table "main_city"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1972; 0 17110 TABLE DATA main_city user
pg_restore: [archiver (db)] COPY failed: ERROR:  duplicate key value violates unique constraint "main_city_pkey"
CONTEXT:  COPY main_city, line 1: "1    London  20  30  4   1"
pg_restore: setting owner and privileges for TABLE DATA main_city
WARNING: errors ignored on restore: 1

Process returned exit code 1.

Shall I try another postgresql client? It is a pain if I try to remove all those references and try to update manually. Any help would be appreciated!


I know nothing about pgAdmin but how about adding the data from the file into a temporary table and the updating/inserting it into the original table depending on if rows exist or not?

0

精彩评论

暂无评论...
验证码 换一张
取 消