CREATE_SERVER(7pg16)

πŸ“¦ version 16.15, in opensuse-leap 16.0

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 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.
  • 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:


mwah β€” CREATE SERVER(7) from PostgreSQL 16.15, dated 2026, signing off πŸ’–

πŸ“¦ where this page comes from