CREATE SERVER
Defines a new foreign server.
Synopsis
CREATE SERVER <server_name> [ TYPE '<server_type>' ] [ VERSION '<server_version>' ]
FOREIGN DATA WRAPPER <fdw_name>
[ OPTIONS ( [ mpp_execute { 'master' | 'any' | 'all segments' } [, ] ]
[ num_segments '<num>' [, ] ]
[ <option> '<value>' [, ... ]] ) ]
Description
CREATE SERVER defines a new foreign server.
The user who defines the server becomes its owner.
A foreign server typically encapsulates connection information that a foreign data wrapper uses to access an external data source.
Additional user-specific connection information may be specified by means of user mappings.
Creating a server requires the USAGE privilege on the foreign data wrapper specified.
Parameters
| Parameter | Description |
|---|---|
server_name |
The name of the foreign server to create. The server name must be unique within the database |
server_type |
Optional server type, potentially useful to foreign data wrappers |
server_version |
Optional server version, potentially useful to foreign data wrappers |
fdw_name |
Name of the foreign data wrapper that manages the server |
OPTIONS ( <option> '<value>' [, … ] ) |
The options for the new foreign server. The options typically define the connection details of the server, but the actual names and values are dependent upon the server’s foreign data wrapper |
mpp_execute { 'master' | 'any' | 'all segments' } |
A Greengage DB-specific option that identifies the host from which the foreign data wrapper reads or writes data:
Support for the foreign server The |
num_segments '<num>' |
When Support for the foreign server |
Notes
When using the dblink module, you can use the foreign server name as an argument of the dblink_connect() function to provide the connection parameters.
You must have the USAGE privilege on the foreign server to use it in this manner.
Examples
Create a foreign server named myserver that uses the foreign data wrapper named pgsql and includes connection options:
CREATE SERVER myserver FOREIGN DATA WRAPPER pgsql
OPTIONS (host 'foo', dbname 'foodb', port '5432');
Compatibility
CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED).