Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

May I alter SERVER for foreign table?

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;
like image 712
Eugen Konkov Avatar asked May 23 '16 10:05

Eugen Konkov


1 Answers

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
like image 91
JustMe Avatar answered Oct 20 '22 22:10

JustMe