]> begriffs open source - ai-pg/blob - full-docs/txt/sql-createserver.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-createserver.txt
1
2 CREATE SERVER
3
4    CREATE SERVER — define a new foreign server
5
6 Synopsis
7
8 CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'se
9 rver_version' ]
10     FOREIGN DATA WRAPPER fdw_name
11     [ OPTIONS ( option 'value' [, ... ] ) ]
12
13 Description
14
15    CREATE SERVER defines a new foreign server. The user who defines the
16    server becomes its owner.
17
18    A foreign server typically encapsulates connection information that a
19    foreign-data wrapper uses to access an external data resource.
20    Additional user-specific connection information may be specified by
21    means of user mappings.
22
23    The server name must be unique within the database.
24
25    Creating a server requires USAGE privilege on the foreign-data wrapper
26    being used.
27
28 Parameters
29
30    IF NOT EXISTS
31           Do not throw an error if a server with the same name already
32           exists. A notice is issued in this case. Note that there is no
33           guarantee that the existing server is anything like the one that
34           would have been created.
35
36    server_name
37           The name of the foreign server to be created.
38
39    server_type
40           Optional server type, potentially useful to foreign-data
41           wrappers.
42
43    server_version
44           Optional server version, potentially useful to foreign-data
45           wrappers.
46
47    fdw_name
48           The name of the foreign-data wrapper that manages the server.
49
50    OPTIONS ( option 'value' [, ... ] )
51           This clause specifies the options for the server. The options
52           typically define the connection details of the server, but the
53           actual names and values are dependent on the server's
54           foreign-data wrapper.
55
56 Notes
57
58    When using the dblink module, a foreign server's name can be used as an
59    argument of the dblink_connect function to indicate the connection
60    parameters. It is necessary to have the USAGE privilege on the foreign
61    server to be able to use it in this way.
62
63    If the foreign server supports sort pushdown, it is necessary for it to
64    have the same sort ordering as the local server.
65
66 Examples
67
68    Create a server myserver that uses the foreign-data wrapper
69    postgres_fdw:
70 CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', db
71 name 'foodb', port '5432');
72
73    See postgres_fdw for more details.
74
75 Compatibility
76
77    CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED).
78
79 See Also
80
81    ALTER SERVER, DROP SERVER, CREATE FOREIGN DATA WRAPPER, CREATE FOREIGN
82    TABLE, CREATE USER MAPPING