I would like to update a field that has been delete from the backup database. how can I update the field from an other database


If you want to write an SQL statement that affects tables from different databases, the best option is to use a postgres_fdw foreign table.

But perhaps it is simpler to extract the data from one database to a file using COPY and to load the file into the other database.


I solved I by using dblink

I created the extension


then I used it as:

UPDATE my_table t SET  column_name=i.column_name, 
FROM  dblink('dbname=other_db','SELECT id, x_column_name FROM my_table') as i(id INT, column_name TEXT) where t.id=i.id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.