Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

postgresql - Do local versions of postgres foreign data wrappers update automatically?

Apologies if this is answered in the docs or somewhere else obvious, but I have just gone through the rigmorale of having to use postgres_fdw to get data from another database (quite different to the ease of MS SQL!)

I ran an IMPORT SCHEMA statement to get the foreign table/databse data into my working database. Will the data in this schema automatially update whenever the data in the foreign database updates or is this IMPORT SCHEMA a copy of the data?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A foreign table does not contain any data. Querying it will yield the current data in the remote table. Think of it as something like a view.

If you are talking about metadata changes (ALTER TABLE), the analogy to views is also helpful: such changes will not be reflected in the foreign table, and you need to run an ALTER FOREIGN TABLE statement.

Perhaps it would make sense to put the data for these databases in a single database in two different schemas.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...