doc: ALTER DEFAULT PRIVILEGES does not affect inherited roles
[pgsql.git] / doc / src / sgml / ref / create_server.sgml
blob05f4019453ba2d9ed07e31ef89cb6fd344e96697
1 <!--
2 doc/src/sgml/ref/create_server.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="sql-createserver">
7 <indexterm zone="sql-createserver">
8 <primary>CREATE SERVER</primary>
9 </indexterm>
11 <refmeta>
12 <refentrytitle>CREATE SERVER</refentrytitle>
13 <manvolnum>7</manvolnum>
14 <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
17 <refnamediv>
18 <refname>CREATE SERVER</refname>
19 <refpurpose>define a new foreign server</refpurpose>
20 </refnamediv>
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>
30 <refsect1>
31 <title>Description</title>
33 <para>
34 <command>CREATE SERVER</command> defines a new foreign server. The
35 user who defines the server becomes its owner.
36 </para>
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>
45 <para>
46 The server name must be unique within the database.
47 </para>
49 <para>
50 Creating a server requires <literal>USAGE</literal> privilege on the
51 foreign-data wrapper being used.
52 </para>
53 </refsect1>
55 <refsect1>
56 <title>Parameters</title>
58 <variablelist>
59 <varlistentry>
60 <term><literal>IF NOT EXISTS</literal></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>
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>
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>
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>
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>
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>
121 <refsect1>
122 <title>Notes</title>
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>
133 <para>
134 If the foreign server supports sort pushdown, it is necessary for it
135 to have the same sort ordering as the local server.
136 </para>
137 </refsect1>
139 <refsect1>
140 <title>Examples</title>
142 <para>
143 Create a server <literal>myserver</literal> that uses the
144 foreign-data wrapper <literal>postgres_fdw</literal>:
145 <programlisting>
146 CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
147 </programlisting>
148 See <xref linkend="postgres-fdw"/> for more details.
149 </para>
150 </refsect1>
152 <refsect1>
153 <title>Compatibility</title>
155 <para>
156 <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
157 </para>
158 </refsect1>
160 <refsect1>
161 <title>See Also</title>
163 <simplelist type="inline">
164 <member><xref linkend="sql-alterserver"/></member>
165 <member><xref linkend="sql-dropserver"/></member>
166 <member><xref linkend="sql-createforeigndatawrapper"/></member>
167 <member><xref linkend="sql-createforeigntable"/></member>
168 <member><xref linkend="sql-createusermapping"/></member>
169 </simplelist>
170 </refsect1>
172 </refentry>