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