CREATE_SERVER(7pg16)
CREATE_SERVER β define a new foreign server β¨π
okay so bestie, welcome to the CREATE_SERVER(7) page from the PostgreSQL 16.15 Documentation π«Ά this is the whole vibe where you define a new foreign server, and yes itβs lowkey iconic. Weβre keeping every tech fact exactly where it belongs β no cap.
πΈ NAME πΈ
CREATE_SERVER β define a new foreign server.
π SYNOPSIS π
hereβs the shape of the spell, fr fr:
CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
FOREIGN DATA WRAPPER fdw_name
[ OPTIONS ( option 'value' [, ... ] ) ]
π DESCRIPTION π
CREATE SERVER defines a new foreign server. The user who defines the server becomes its owner β main character energy, honestly π.
The way this works: 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.
The server name must be unique within the database β no duplicates, periodt π«.
Creating a server requires USAGE privilege on the foreign-data wrapper being used. Thatβs the vibe check β
.
β¨ PARAMETERS β¨
IF NOT EXISTSβ 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.
so likeβ¦ it might exist, but it could be a whole different creature π
server_nameβ the name of the foreign server to be created.server_typeβ optional server type, potentially useful to foreign-data wrappers.server_versionβ optional server version, potentially useful to foreign-data wrappers.fdw_nameβ the name of the foreign-data wrapper that manages the server.OPTIONS ( option 'value' [, ... ] )β 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.
π¦ NOTES π¦
- When using the
dblinkmodule, a foreign serverβs name can be used as an argument of thedblink_connect(3)function to indicate the connection parameters. It is necessary to have theUSAGEprivilege on the foreign server to be able to use it in this way. - If the foreign server supports sort pushdown, it is necessary for it to have the same sort ordering as the local server. iykyk π§
π EXAMPLES π
Create a server myserver that uses the foreign-data wrapper postgres_fdw β cute:
CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
See postgres_fdw for more details. that one ate π
β COMPATIBILITY β
CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED). β
π SEE ALSO π
the whole friend group:
ALTER SERVER(ALTER_SERVER(7))DROP SERVER(DROP_SERVER(7))CREATE FOREIGN DATA WRAPPER(CREATE_FOREIGN_DATA_WRAPPER(7))CREATE FOREIGN TABLE(CREATE_FOREIGN_TABLE(7))CREATE USER MAPPING(CREATE_USER_MAPPING(7))
mwah β CREATE SERVER(7) from PostgreSQL 16.15, dated 2026, signing off π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms