CREATE_SERVER(7pg17)

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

✨ CREATE_SERVER ✨

okay so bestie, welcome to CREATE_SERVER(7) from the PostgreSQL 17.11 Documentation. It’s giving β€œdefine a new foreign server” main character energy, and we’re gonna cover every single detail. πŸ«ΆπŸ’…

🌸 NAME 🌸

CREATE_SERVER β€” define a new foreign server. periodt. πŸ’–

✨ SYNOPSIS ✨

CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
    FOREIGN DATA WRAPPER fdw_name
    [ OPTIONS ( option 'value' [, ... ] ) ]

this is the whole shape of the command β€” no cap, that’s the synopsis. ✨

πŸ’– DESCRIPTION πŸ’–

CREATE SERVER defines a new foreign server. The user who defines the server becomes its owner. slay, ownership acquired. πŸ‘‘

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. iykyk β€” user mappings are a whole vibe. πŸ¦‹

The server name must be unique within the database. no cap, no duplicate server names, bestie. πŸ’…

Creating a server requires USAGE privilege on the foreign-data wrapper being used. That’s the vibe check: no USAGE, no server creation. 😭

πŸŽ€ 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. literally, it might be a totally different vibe. πŸ™ˆ
  • server_name β€” the name of the foreign server to be created. iconic. ⭐
  • 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. it’s giving manager energy. πŸ‘‘
  • 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. periodt. πŸ’«

If the foreign server supports sort pushdown, it is necessary for it to have the same sort ordering as the local server. fr fr. πŸ“

🌈 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. obsessed. ✨

⭐ COMPATIBILITY ⭐

CREATE SERVER conforms to ISO/IEC 9075-9 (SQL/MED). periodt. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’‹ β€” this page is from PostgreSQL 17.11, dated 2026, and its manual name is CREATE SERVER(7). go be the main character of your own foreign server, bestie. 🫢✨

πŸ“¦ where this page comes from