1CREATE SERVER(7)         PostgreSQL 16.1 Documentation        CREATE SERVER(7)
2
3
4

NAME

6       CREATE_SERVER - define a new foreign server
7

SYNOPSIS

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

DESCRIPTION

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

PARAMETERS

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

NOTES

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
59       If the foreign server supports sort pushdown, it is necessary for it to
60       have the same sort ordering as the local server.
61

EXAMPLES

63       Create a server myserver that uses the foreign-data wrapper
64       postgres_fdw:
65
66           CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
67
68       See postgres_fdw for more details.
69

COMPATIBILITY

71       CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED).
72

SEE ALSO

74       ALTER SERVER (ALTER_SERVER(7)), DROP SERVER (DROP_SERVER(7)), CREATE
75       FOREIGN DATA WRAPPER (CREATE_FOREIGN_DATA_WRAPPER(7)), CREATE FOREIGN
76       TABLE (CREATE_FOREIGN_TABLE(7)), CREATE USER MAPPING
77       (CREATE_USER_MAPPING(7))
78
79
80
81PostgreSQL 16.1                      2023                     CREATE SERVER(7)
Impressum