6
  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?

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Zuojia Jiang
  • 65
  • 1
  • 4

1 Answers1

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;
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263