]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/create_server.sgml
Add support for piping COPY to/from an external program.
[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  <refmeta>
8   <refentrytitle>CREATE SERVER</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>CREATE SERVER</refname>
15   <refpurpose>define a new foreign server</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-createserver">
19   <primary>CREATE SERVER</primary>
20  </indexterm>
21
22  <refsynopsisdiv>
23 <synopsis>
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>' [, ... ] ) ]
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><replaceable class="parameter">server_name</replaceable></term>
61     <listitem>
62      <para>
63       The name of the foreign server to be created.
64      </para>
65     </listitem>
66    </varlistentry>
67
68    <varlistentry>
69     <term><replaceable class="parameter">server_type</replaceable></term>
70     <listitem>
71      <para>
72       Optional server type, potentially useful to foreign-data wrappers.
73      </para>
74     </listitem>
75    </varlistentry>
76
77    <varlistentry>
78     <term><replaceable class="parameter">server_version</replaceable></term>
79     <listitem>
80      <para>
81       Optional server version, potentially useful to foreign-data wrappers.
82      </para>
83     </listitem>
84    </varlistentry>
85
86    <varlistentry>
87     <term><replaceable class="parameter">fdw_name</replaceable></term>
88     <listitem>
89      <para>
90       The name of the foreign-data wrapper that manages the server.
91      </para>
92     </listitem>
93    </varlistentry>
94
95    <varlistentry>
96     <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] )</literal></term>
97     <listitem>
98      <para>
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.
103      </para>
104     </listitem>
105    </varlistentry>
106   </variablelist>
107  </refsect1>
108
109  <refsect1>
110   <title>Notes</title>
111
112   <para>
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.
119   </para>
120  </refsect1>
121
122  <refsect1>
123   <title>Examples</title>
124
125   <para>
126    Create a server <literal>myserver</> that uses the
127    foreign-data wrapper <literal>postgres_fdw</>:
128 <programlisting>
129 CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
130 </programlisting>
131    See <xref linkend="postgres-fdw"> for more details.
132   </para>
133  </refsect1>
134
135  <refsect1>
136   <title>Compatibility</title>
137
138   <para>
139    <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
140   </para>
141  </refsect1>
142
143  <refsect1>
144   <title>See Also</title>
145
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>
152   </simplelist>
153  </refsect1>
154
155 </refentry>