All Products
Search
Document Center

Hologres:ALTER FOREIGN TABLE

Last Updated:Dec 02, 2024

You can execute the ALTER FOREIGN TABLE statement to modify a foreign table. This topic describes how to execute the ALTER FOREIGN TABLE statement to rename a foreign table, add columns to a foreign table, or drop columns from a foreign table.

Limits

Hologres allows you to execute the ALTER FOREIGN TABLE statement only to rename a foreign table, add columns to a foreign table, or drop columns from a foreign table.

Rename a foreign table

Syntax:

ALTER FOREIGN TABLE [ IF EXISTS ] name RENAME TO new_name;    

Sample SQL statement:

ALTER FOREIGN TABLE test RENAME TO new_test_table; 

Add a column to a table

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

Note
  • You cannot add columns to a shared cluster by executing the following statements. For more information about how to add columns to a shared cluster, see IMPORT FOREIGN SCHEMA.

Syntax:

ALTER FOREIGN TABLE IF EXISTS table_name ADD COLUMN new_column_name data_type;

Sample SQL statements:

ALTER FOREIGN TABLE bank
 ADD COLUMN  cons_conf_idx float8,
 ADD COLUMN  euribor3m float8;

Drop a column

Syntax:

ALTER FOREIGN TABLE IF EXISTS table_name DROP COLUMN column_name;

Sample SQL statements:

ALTER FOREIGN TABLE bank
 DROP COLUMN  cons_conf_idx;