2 doc/src/sgml/ref/create_server.sgml
3 PostgreSQL documentation
6 <refentry id="SQL-CREATESERVER">
8 <refentrytitle>CREATE SERVER</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
14 <refname>CREATE SERVER</refname>
15 <refpurpose>define a new foreign server</refpurpose>
18 <indexterm zone="sql-createserver">
19 <primary>CREATE SERVER</primary>
24 CREATE SERVER <replaceable class="parameter">server_name</replaceable> [ TYPE '<replaceable class="parameter">server_type</replaceable>' ] [ VERSION '<replaceable class="parameter">server_version</replaceable>' ]
25 FOREIGN DATA WRAPPER <replaceable class="parameter">fdw_name</replaceable>
26 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
31 <title>Description</title>
34 <command>CREATE SERVER</command> defines a new foreign server. The
35 user who defines the server becomes its owner.
39 A foreign server typically encapsulates connection information that
40 a foreign-data wrapper uses to access an external data resource.
41 Additional user-specific connection information may be specified by
42 means of user mappings.
46 The server name must be unique within the database.
50 Creating a server requires <literal>USAGE</> privilege on the
51 foreign-data wrapper being used.
56 <title>Parameters</title>
60 <term><replaceable class="parameter">server_name</replaceable></term>
63 The name of the foreign server to be created.
69 <term><replaceable class="parameter">server_type</replaceable></term>
72 Optional server type, potentially useful to foreign-data wrappers.
78 <term><replaceable class="parameter">server_version</replaceable></term>
81 Optional server version, potentially useful to foreign-data wrappers.
87 <term><replaceable class="parameter">fdw_name</replaceable></term>
90 The name of the foreign-data wrapper that manages the server.
96 <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] )</literal></term>
99 This clause specifies the options for the server. The options
100 typically define the connection details of the server, but the
101 actual names and values are dependent on the server's
102 foreign-data wrapper.
113 When using the <xref linkend="dblink"> module,
114 a foreign server's name can be used
115 as an argument of the <xref linkend="contrib-dblink-connect">
116 function to indicate the connection parameters. It is necessary to have
117 the <literal>USAGE</literal> privilege on the foreign server to be
118 able to use it in this way.
123 <title>Examples</title>
126 Create a server <literal>myserver</> that uses the
127 foreign-data wrapper <literal>postgres_fdw</>:
129 CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
131 See <xref linkend="postgres-fdw"> for more details.
136 <title>Compatibility</title>
139 <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
144 <title>See Also</title>
146 <simplelist type="inline">
147 <member><xref linkend="sql-alterserver"></member>
148 <member><xref linkend="sql-dropserver"></member>
149 <member><xref linkend="sql-createforeigndatawrapper"></member>
150 <member><xref linkend="sql-createforeigntable"></member>
151 <member><xref linkend="sql-createusermapping"></member>