0

I have a local table with many fields. I need to update the values on a different server(same db structure) just for one column. How can I do this ?

0

2 Answers 2

1

have yout tried dblink?

SELECT INTO AFFECTED_ROW_COUNT_STRING 
DBLINK_EXEC('host=localhost  port=5432 dbname=DBNAME user=USERNAME password=PASSWORD', 
'UPDATE TABLE SET COLUMN = VALUE ');
Sign up to request clarification or add additional context in comments.

Comments

0

The only way I can think of is to return the changed column in the results and to apply the changes on both servers.

create table test123 {
    id serial primary key,
    myvalue int4
};

Assume, you have rows from 1 to 100 in both tables on both servers. This statement updates your rows, and produces a single string result with update statements you can do on the other server also.

update test123 set myvalue = rand() 
returning 'UPDATE test123 SET myvalue='||test123||' WHERE id='||id||';';

PS: Untested, but should work with minor syntax fixes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.