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