]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/create_server.sgml
Trim trailing whitespace
[postgresql] / doc / src / sgml / ref / create_server.sgml
1 <!--
2 doc/src/sgml/ref/create_server.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-CREATESERVER">
7  <indexterm zone="sql-createserver">
8   <primary>CREATE SERVER</primary>
9  </indexterm>
10
11  <refmeta>
12   <refentrytitle>CREATE SERVER</refentrytitle>
13   <manvolnum>7</manvolnum>
14   <refmiscinfo>SQL - Language Statements</refmiscinfo>
15  </refmeta>
16
17  <refnamediv>
18   <refname>CREATE SERVER</refname>
19   <refpurpose>define a new foreign server</refpurpose>
20  </refnamediv>
21
22  <refsynopsisdiv>
23 <synopsis>
24 CREATE SERVER [IF NOT EXISTS] <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>' [, ... ] ) ]
27 </synopsis>
28  </refsynopsisdiv>
29
30  <refsect1>
31   <title>Description</title>
32
33   <para>
34    <command>CREATE SERVER</command> defines a new foreign server.  The
35    user who defines the server becomes its owner.
36   </para>
37
38   <para>
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.
43   </para>
44
45   <para>
46    The server name must be unique within the database.
47   </para>
48
49   <para>
50    Creating a server requires <literal>USAGE</> privilege on the
51    foreign-data wrapper being used.
52   </para>
53  </refsect1>
54
55  <refsect1>
56   <title>Parameters</title>
57
58   <variablelist>
59   <varlistentry>
60     <term><literal>IF NOT EXISTS</></term>
61     <listitem>
62      <para>
63       Do not throw an error if a server with the same name already exists.
64       A notice is issued in this case.  Note that there is no guarantee that
65       the existing server is anything like the one that would have been
66       created.
67      </para>
68     </listitem>
69    </varlistentry>
70
71    <varlistentry>
72     <term><replaceable class="parameter">server_name</replaceable></term>
73     <listitem>
74      <para>
75       The name of the foreign server to be created.
76      </para>
77     </listitem>
78    </varlistentry>
79
80    <varlistentry>
81     <term><replaceable class="parameter">server_type</replaceable></term>
82     <listitem>
83      <para>
84       Optional server type, potentially useful to foreign-data wrappers.
85      </para>
86     </listitem>
87    </varlistentry>
88
89    <varlistentry>
90     <term><replaceable class="parameter">server_version</replaceable></term>
91     <listitem>
92      <para>
93       Optional server version, potentially useful to foreign-data wrappers.
94      </para>
95     </listitem>
96    </varlistentry>
97
98    <varlistentry>
99     <term><replaceable class="parameter">fdw_name</replaceable></term>
100     <listitem>
101      <para>
102       The name of the foreign-data wrapper that manages the server.
103      </para>
104     </listitem>
105    </varlistentry>
106
107    <varlistentry>
108     <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] )</literal></term>
109     <listitem>
110      <para>
111       This clause specifies the options for the server.  The options
112       typically define the connection details of the server, but the
113       actual names and values are dependent on the server's
114       foreign-data wrapper.
115      </para>
116     </listitem>
117    </varlistentry>
118   </variablelist>
119  </refsect1>
120
121  <refsect1>
122   <title>Notes</title>
123
124   <para>
125    When using the <xref linkend="dblink"> module,
126    a foreign server's name can be used
127    as an argument of the <xref linkend="contrib-dblink-connect">
128    function to indicate the connection parameters.  It is necessary to have
129    the <literal>USAGE</literal> privilege on the foreign server to be
130    able to use it in this way.
131   </para>
132  </refsect1>
133
134  <refsect1>
135   <title>Examples</title>
136
137   <para>
138    Create a server <literal>myserver</> that uses the
139    foreign-data wrapper <literal>postgres_fdw</>:
140 <programlisting>
141 CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
142 </programlisting>
143    See <xref linkend="postgres-fdw"> for more details.
144   </para>
145  </refsect1>
146
147  <refsect1>
148   <title>Compatibility</title>
149
150   <para>
151    <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
152   </para>
153  </refsect1>
154
155  <refsect1>
156   <title>See Also</title>
157
158   <simplelist type="inline">
159    <member><xref linkend="sql-alterserver"></member>
160    <member><xref linkend="sql-dropserver"></member>
161    <member><xref linkend="sql-createforeigndatawrapper"></member>
162    <member><xref linkend="sql-createforeigntable"></member>
163    <member><xref linkend="sql-createusermapping"></member>
164   </simplelist>
165  </refsect1>
166
167 </refentry>