Add some more documentation and cross-links on using dblink with SQL/MED.
[PostgreSQL.git] / doc / src / sgml / ref / create_server.sgml
bloba4bedcec036a3d7ce16a2f2b9fef256ca66b8efa
1 <!--
2 $PostgreSQL$
3 PostgreSQL documentation
4 -->
6 <refentry id="SQL-CREATESERVER">
7 <refmeta>
8 <refentrytitle id="sql-createserver-title">CREATE SERVER</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
10 </refmeta>
12 <refnamediv>
13 <refname>CREATE SERVER</refname>
14 <refpurpose>define a new foreign server</refpurpose>
15 </refnamediv>
17 <indexterm zone="sql-createserver">
18 <primary>CREATE SERVER</primary>
19 </indexterm>
21 <refsynopsisdiv>
22 <synopsis>
23 CREATE SERVER <replaceable class="parameter">servername</replaceable> [ TYPE 'servertype' ] [ VERSION 'serverversion' ]
24 FOREIGN DATA WRAPPER <replaceable class="parameter">fdwname</replaceable>
25 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
26 </synopsis>
27 </refsynopsisdiv>
29 <refsect1>
30 <title>Description</title>
32 <para>
33 <command>CREATE SERVER</command> defines a new foreign server. The
34 user who defines the server becomes its owner.
35 </para>
37 <para>
38 A foreign server typically encapsulates connection information that
39 a foreign-data wrapper uses to access an external data resource.
40 Additional user-specific connection information may be specified by
41 means of user mappings.
42 </para>
44 <para>
45 The server name must be unique within the database.
46 </para>
48 <para>
49 Creating a server requires <literal>USAGE</> privilege on the
50 foreign-data wrapper being used.
51 </para>
52 </refsect1>
54 <refsect1>
55 <title>Parameters</title>
57 <variablelist>
58 <varlistentry>
59 <term><replaceable class="parameter">servername</replaceable></term>
60 <listitem>
61 <para>
62 The name of the foreign server to be created.
63 </para>
64 </listitem>
65 </varlistentry>
67 <varlistentry>
68 <term><replaceable class="parameter">servertype</replaceable></term>
69 <listitem>
70 <para>
71 Optional server type.
72 </para>
73 </listitem>
74 </varlistentry>
76 <varlistentry>
77 <term><replaceable class="parameter">serverversion</replaceable></term>
78 <listitem>
79 <para>
80 Optional server version.
81 </para>
82 </listitem>
83 </varlistentry>
85 <varlistentry>
86 <term><replaceable class="parameter">fdwname</replaceable></term>
87 <listitem>
88 <para>
89 The name of the foreign-data wrapper that manages the server.
90 </para>
91 </listitem>
92 </varlistentry>
94 <varlistentry>
95 <term><literal>OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] )</literal></term>
96 <listitem>
97 <para>
98 This clause specifies the options for the server. The options
99 typically define the connection details of the server, but the
100 actual names and values are dependent on the server's
101 foreign-data wrapper.
102 </para>
103 </listitem>
104 </varlistentry>
105 </variablelist>
106 </refsect1>
108 <refsect1>
109 <title>Notes</title>
111 <para>
112 When using the <application>dblink</application> module
113 (see <xref linkend="dblink">), the foreign server name can be used
114 as an argument of the <xref linkend="contrib-dblink-connect">
115 function to indicate the connection parameters. See also there for
116 more examples. 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>
122 <refsect1>
123 <title>Examples</title>
125 <para>
126 Create a server <literal>foo</> that uses the built-in foreign-data
127 wrapper <literal>default</>:
128 <programlisting>
129 CREATE SERVER foo FOREIGN DATA WRAPPER "default";
130 </programlisting>
131 </para>
133 <para>
134 Create a server <literal>myserver</> that uses the
135 foreign-data wrapper <literal>pgsql</>:
136 <programlisting>
137 CREATE SERVER myserver FOREIGN DATA WRAPPER pgsql OPTIONS (host 'foo', dbname 'foodb', port '5432');
138 </programlisting>
139 </para>
140 </refsect1>
142 <refsect1>
143 <title>Compatibility</title>
145 <para>
146 <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
147 </para>
148 </refsect1>
150 <refsect1>
151 <title>See Also</title>
153 <simplelist type="inline">
154 <member><xref linkend="sql-alterserver" endterm="sql-alterserver-title"></member>
155 <member><xref linkend="sql-dropserver" endterm="sql-dropserver-title"></member>
156 <member><xref linkend="sql-createforeigndatawrapper" endterm="sql-createforeigndatawrapper-title"></member>
157 <member><xref linkend="sql-createusermapping" endterm="sql-createusermapping-title"></member>
158 </simplelist>
159 </refsect1>
161 </refentry>