ALTER FOREIGN TABLE

Synopsis

Use the ALTER FOREIGN TABLE command to alter a foreign table.

Syntax

alter_foreign_table ::= ALTER FOREIGN TABLE [ IF EXISTS ] table_name 
                        alter_foreign_table_action [ , ... ]

alter_foreign_table

ALTERFOREIGNTABLEIFEXISTStable_name,alter_foreign_table_action

Semantics

Alter the foreign table named table_name.

Add a column

The ADD COLUMN clause can be used to add a new column to the foreign table. There's no effect on the underlying storage: the ADD COLUMN action just indicates that the newly added column can be accessed through the foreign table.

Drop a column

The DROP COLUMN clause can be used to drop a column from the foreign table. CASCADE or RESTRICT can be specified.

Change owner

The OWNER TO clause can be used to specify the new_owner.

Options

The OPTIONS clause can be used to specify the new options of the foreign table. ADD, SET, and DROP specify the action to be performed. ADD is assumed if no operation is explicitly specified.

Rename

The RENAME TO clause can be used to rename the foreign table to table_name.

Examples

Adding a new column.

yugabyte=# ALTER FOREIGN TABLE my_table ADD COLUMN new_col int;

Change the options.

yugabyte=# ALTER FOREIGN TABLE my_table OPTIONS (ADD newopt1 'value1', DROP oldopt1 'value2', SET oldopt2 'value3');

See also