CREATE SERVER

Define a new external server.

Summary

CREATE SERVER server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
    FOREIGN DATA WRAPPER fdw_name
    [ OPTIONS ( [ mpp_execute { 'master' | 'any' | 'all segments' } [, ] ] option 'value' [, ... ] ) ]

describe

CREATE SERVER Defines a new external server. The user who defines the server will become its owner.

External servers usually encapsulate external data wrappers to access connection information from external data sources. Other user-specific connection information can be specified through user mapping.

Creating a server requires USAGE privileges to the specified external data wrapper.

Parameters

server_name

  • The name of the external server to be created. The server name must be unique in the database.

server_type

  • Optional server type, which may be useful for external data wrappers.

server_version

  • Optional server version, which may be useful for external data wrappers.

fdw_name

  • The name of the external data wrapper that manages the server.

OPTIONS ( option 'value' [, ... ] )

  • Options for new external servers. These options usually define the server's connection details, but the actual name and value depend on the server's external data wrapper.

mpp_execute { 'master' | 'any' | 'all segments' }

  • An option to identify the host from which the external data wrapper requests data:
    • master (default setting) - Request data from the Master host.
    • any — Request data from the Master host or any Segment, depending on which path is less expensive.
    • all segments — Request data from all segments. To support this option value, the external data wrapper must have a policy that matches the Segment to the data.
  • The mpp_execute options can be specified in multiple commands: CREATE FOREIGN TABLE, CREATE SERVER, and CREATE FOREIGN DATA WRAPPER. External table settings take precedence over external server settings, followed by external data wrapper settings.

Note

When using the dblink module (see dblink), the external server name can be used as a parameter to the dblink_connect() function to provide connection parameters. You must have USAGE privileges on an external server to use it this way.

Example

Create an external server called myserver that uses an external data wrapper named pgsql and contains connection options:

CREATE SERVER myserver FOREIGN DATA WRAPPER pgsql
    OPTIONS (host 'foo', dbname 'foodb', port '5432');

compatibility

CREATE SERVER complies with ISO/IEC 9075-9 (SQL/MED).

See also

ALTER SERVER, DROP SERVER