updating table with Postgresql Foreign data wrapper
Asked Answered
S

1

7
  1. I created a foreign data wrapper table named t_user into mySchema.

    IMPORT FOREIGN SCHEMA public LIMIT TO (t_user)
       FROM SERVER myServer INTO mySchema;
    
  2. The myServer side t_user added some column, but the foreign table didn't update accordingly.

  3. I tried to delete the foreign table t_user, but it was used by my view and materialized view t_user, so the deletion failed.

Any ideas on how to update this table?

Suggestibility answered 12/12, 2018 at 6:4 Comment(0)
A
7

As you have seen, the foreign table definition does not change when the underlying table changes.

If all you did is add a column, you can use ALTER FOREIGN TABLE to add a corresponding column to the foreign table. That should work even if views depend on the foreign table.

For example, if the column is of type text, you can do:

ALTER FOREIGN TABLE t_user ADD COLUMN my_column text;
Allopath answered 12/12, 2018 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.