---
title: "ALTER FOREIGN TABLE"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_alter_foreign_table/"
---

# ALTER FOREIGN TABLE

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

## Synopsis

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

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

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

#### alter\_foreign\_table

ALTERFOREIGNTABLEIFEXISTS[table\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#table-name),[alter\_foreign\_table\_action](/stable/api/ysql/syntax_resources/grammar_diagrams#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.

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

Change the options.

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

## See also

- [CREATE FOREIGN TABLE](/stable/api/ysql/the-sql-language/statements/ddl_create_foreign_table/ "CREATE FOREIGN TABLE")
- [DROP FOREIGN TABLE](/stable/api/ysql/the-sql-language/statements/ddl_drop_foreign_table/ "DROP FOREIGN TABLE")
