Can I change the SERVER for an external table?

According to the DOC, I cannot do this. But a complete recreation of the table forces me to do a huge job instead of a simple one:

ALTER FOREIGN TABLE table_name ALTER SERVER new_server_name;
+5
source share
2 answers

List your external data servers and note this:

select oid, * from pg_foreign_server 

Find your external table:

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

Then change the system directory pg_foreign_tableas:

update pg_foreign_table set ftserver = 11573931 where ftserver = 11573932 -- and ftrelid = YOUR_OID_RELID_FROM_PG_CLASS
+5
source

Do not change the server in this way, because it will not update the pg_depend dependency table and will cause many problems later.

0
source

All Articles