CREATE_SERVER(7pg14)
π CREATE SERVER β like, define a new foreign server, bestie
okay so this is the CREATE SERVER(7) page from the PostgreSQL 14.24 docs and it's genuinely iconic β it's the one that teaches you how to spin up a brand-new foreign server. let's get into it π«Ά
β¨ NAME β¨
CREATE_SERVER β define a new foreign server. that's it. that's the whole vibe. π
π SYNOPSIS π
CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
FOREIGN DATA WRAPPER fdw_name
[ OPTIONS ( option 'value' [, ... ] ) ]
look at that syntax. gorgeous. no notes. π
πΈ DESCRIPTION πΈ
CREATE SERVER defines a new foreign server. and the way that you, the user who defines it, automatically become its owner? main character energy fr fr. π
so a foreign server typically encapsulates connection information that a foreign-data wrapper uses to access an external data resource. think of it as the little bundle of "hey here's where the other database lives" info. β¨ additional user-specific connection information may be specified by means of user mappings β that's how you get per-user deets in there.
the server name must be unique within the database. no duplicates, bestie, i don't make the rules. π
creating a server requires USAGE privilege on the foreign-data wrapper being used. so likeβ¦ you gotta have the permissions. no sneaking in. π₯
π¦ 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 instead, which is way more chill. β but heads up: there is no guarantee that the existing server is anything like the one that would have been created. it could be a whole different vibe. πserver_nameβ the name of the foreign server to be created. you pick it, you own it. πserver_typeβ optional server type, potentially useful to foreign-data wrappers. it's giving "nice to have." πΈserver_versionβ optional server version, potentially useful to foreign-data wrappers. same energy, different field. π¦fdw_nameβ the name of the foreign-data wrapper that manages the server. this is the one in charge, the icon holding it all together. π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. so like, i can't tell you what goes here β ask your FDW, iykyk. π
β NOTES β
when using the dblink module, a foreign server's name can be used as an argument of the dblink_connect(3) function to indicate the connection parameters. it is necessary to have the USAGE privilege on the foreign server to be able to use it in this way. so, again: permissions. always permissions. π
if the foreign server supports sort pushdown, it is necessary for it to have the same sort ordering as the local server. like matching outfits but for sort orders. π
π₯ EXAMPLES π₯
create a server myserver that uses the foreign-data wrapper postgres_fdw:
CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
ate. no crumbs. π
see postgres_fdw for more details.
π COMPATIBILITY π
CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED). she's certified, she's standards-compliant, she's that girl. β¨
π SEE ALSO π
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))
the whole friend group, honestly. π«Ά
and that's the page!! mwah π β this was PostgreSQL 14.24 documentation, dated 2026, CREATE SERVER(7), signin' off with love. go forth and create servers, bestie π§ββοΈππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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