Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

updating table with Postgresql Foreign data wrapper

  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?

like image 465
Zuojia Jiang Avatar asked Aug 02 '26 20:08

Zuojia Jiang


1 Answers

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;
like image 160
Laurenz Albe Avatar answered Aug 05 '26 12:08

Laurenz Albe