CREATE_SERVER(7pg13)
β¨ CREATE SERVER π
(PostgreSQL 13.23, CREATE_SERVER(7))
okay bestie, so you want to make a whole new foreign server?? iconic. let's get into it π«Ά
πΈ SYNOPSIS πΈ
CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
FOREIGN DATA WRAPPER fdw_name
[ OPTIONS ( option 'value' [, ... ] ) ]
like, that's the whole vibe. read it, love it, respect it β¨
π DESCRIPTION π
CREATE SERVER defines a new foreign server. and the way that whoever creates it just Literally becomes its owner?? main character energy fr fr π
so basically, a foreign server is this lil package of connection info that a foreign-data wrapper uses to go talk to some external data resource. you can also add your own extra user-specific connection deets through user mappings β very demure, very customizable π
the server name has to be unique within the database. no dupes, no copies, no twinsies. periodt π
β οΈ also important bestie: creating a server requires USAGE privilege on the foreign-data wrapper you're using. no privilege, no server. that's just the rules π
π PARAMETERS π
IF NOT EXISTSβ don't throw an error if a server with the same name already exists, just issue a notice instead π but real talk: there's no guarantee the existing server is anything like the one you were about to create. so like... eyes open, bestie πserver_nameβ the name of the foreign server you're creating. pick something cute β¨server_typeβ optional server type, potentially useful to foreign-data wrappers. lowkey optional, highkey helpful π¦server_versionβ optional server version, potentially useful to foreign-data wrappers. same vibe, different field πΈfdw_nameβ the name of the foreign-data wrapper that manages the server. the boss of the operation, if you will πOPTIONS ( option 'value' [, ... ] )β this clause specifies the options for the server. typically these define the connection details of the server, but the actual names and values are dependent on the server's foreign-data wrapper β so check with your fdw, not with me π«Ά
π¦ NOTES π¦
okay so when you're 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. cute, right? BUT β it is necessary to have the USAGE privilege on the foreign server to be able to use it in this way. no privilege, no dblink. sorry babes π
and if the foreign server supports sort pushdown, it is necessary for it to have the same sort ordering as the local server. like, they have to match. matching outfits only π₯
π 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');
see postgres_fdw for more details. she ate, no crumbs π
β COMPATIBILITY β
CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED). standards girlie behavior, we love to see it π
π 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))
that's the whole page bestie, go forth and create servers responsibly π§π
signing off from PostgreSQL 13.23, dated 2025 β mwah, talk soon π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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