Synopsis

Use the CREATE FOREIGN TABLE command to create a foreign table.

Syntax

create_foreign_table ::= CREATE FOREIGN TABLE [ IF NOT EXISTS ] 
                         table_name ( [ foreign_table_elem [ , ... ] ] 
                         )  SERVER server_name 
                         [ OPTIONS ( fdw_options ) ]

create_foreign_table

CREATEFOREIGNTABLEIFNOTEXISTStable_name(,foreign_table_elem)SERVERserver_nameOPTIONS(fdw_options)

Semantics

Create a new foreign table named table_name. If table_name already exists in the specified database, an error will be raised unless the IF NOT EXISTS clause is used.

Collation

The COLLATE clause can be used to specify a collation for the column.

Server

The SERVER clause can be used to specify the name of the foreign server to use.

Options:

The OPTIONS clause specifies options for the foreign table. The permitted option names and values are specific to each foreign data wrapper. The options are validated using the FDW’s validator function.

Examples

Basic example.

yugabyte=#  CREATE FOREIGN TABLE mytable (col1 int, col2 int) SERVER my_server OPTIONS (schema 'external_schema', table 'external_table');

See also