5

According to the DOC I can not do that. But fully recreate table force me to do huge work instead of simple:

ALTER FOREIGN TABLE table_name ALTER SERVER new_server_name;
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158

3 Answers3

6

List your foreign data servers and note it oid:

select oid, * from pg_foreign_server 

Find your foreign table:

select oid, * from pg_class where relkind = 'f'

Then modify system catalog pg_foreign_table like:

update pg_foreign_table set ftserver = 11573931 where ftserver = 11573932 -- and ftrelid = YOUR_OID_RELID_FROM_PG_CLASS
JustMe
  • 2,329
  • 3
  • 23
  • 43
2

In postgres 12 this command worked fine in order to change the server IP address that was used for foreign DB wrapper

alter  server  YOUR_SERVER_NAME  options (set  host 'XX.XXX.XX.X');

Igor Iris
  • 66
  • 3
0

Don't change server using this way, because it will not update dependency table pg_depend and cause many problems later.