You can execute the ALTER FOREIGN TABLE statement to modify a foreign table.

The current Hologres version allows you to execute the ALTER FOREIGN TABLE statement to rename a foreign table, add columns to a foreign table, and delete columns from a foreign table.

Rename foreign table

  1. Synopsis
    ALTER FOREIGN TABLE [ IF EXISTS ] name RENAME TO new_name    
  2. Examples
    ALTER FOREIGN TABLE test RENAME TO new_test_table 

Add columns

Hologres does not automatically update the schema of a created foreign table after columns are added to the mapping MaxCompute table. To query values of the added columns through the foreign table, you must manually add the columns to the foreign table.

  1. Synopsis
    ALTER TABLE IF EXISTS table_name ADD COLUMN new_column_name data_type;
  2. Examples
    ALTER FOREIGN TABLE bank
     ADD COLUMN  cons_conf_idx float8,
     ADD COLUMN  euribor3m float8;

Drop columns

  1. Synopsis
    ALTER TABLE IF EXISTS table_name DROP COLUMN column_name;
  2. Examples
    ALTER FOREIGN TABLE bank
     DROP COLUMN  cons_conf_idx,
     DROP COLUMN  euribor3m;