ALTER_SERVER(7pg14)

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

✨ ALTER SERVER ✨

okay so bestie, welcome to ALTER SERVER β€” the PostgreSQL 14.24 glow-up page for foreign servers πŸ’… this is where you change the definition of a foreign server, and yes it's as iconic as it sounds. (it's a section 7 page in the PostgreSQL 14.24 docs, if you're keeping track πŸŽ€)


🌸 SYNOPSIS 🌸

ALTER SERVER name [ VERSION 'new_version' ]
    [ OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] ) ]
ALTER SERVER name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER SERVER name RENAME TO new_name

πŸ’– DESCRIPTION πŸ’–

ALTER SERVER changes the definition of a foreign server. that's the whole vibe ✨

the first form changes the server version string or the generic options of the server β€” and heads up, at least one clause is required, you can't just send it an empty text and expect anything πŸ”₯

the second form changes the owner of the server. new main character, same server πŸ‘‘

to alter the server you must be the svr owner. and ooh, the owner-change is the strict one: to alter the owner you must own the server and also be a direct or indirect member of the new owning role, and you must have USAGE privilege on the server's foreign-data wrapper. that's three whole vibe checks 😭 (but ngl, superusers satisfy all these criteria automatically β€” they're built different fr fr 🧚)


πŸ¦‹ PARAMETERS πŸ¦‹

  • name β€” the name of an existing server. like, one that already exists, don't come at me with a made-up name πŸ™ˆ
  • new_version β€” new server version. literally just the new version, slay.
  • OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] ) β€” change options for the server. ADD, SET, and DROP specify the action to be performed, and ADD is assumed if no operation is explicitly specified (default behaviour, we love to see it ⭐). Option names must be unique β€” no duplicates bestie, that's not the move πŸ’€ β€” and heads up, names and values are also validated using the server's foreign-data wrapper library.
  • new_owner β€” the user name of the new owner of the foreign server. πŸ‘‘
  • new_name β€” the new name for the foreign server. fresh name, fresh era 🌈

πŸŽ€ EXAMPLES πŸŽ€

Alter server foo, add connection options:

ALTER SERVER foo OPTIONS (host 'foo', dbname 'foodb');

Alter server foo, change version, change host option:

ALTER SERVER foo VERSION '8.4' OPTIONS (SET host 'baz');

see how clean that is?? obsessed 🫢


πŸ’€ COMPATIBILITY πŸ’€

ALTER SERVER conforms to ISO/IEC 9075-9 (SQL/MED) β€” standards girlie behaviour πŸ’… but the OWNER TO and RENAME forms are PostgreSQL extensions, so that's us, being extra, as usual ✨


πŸ‘‘ SEE ALSO πŸ‘‘

iykyk β€” go read those too, they're the whole friend group πŸ¦‹


and that's the page, bestie! brought to you by PostgreSQL 14.24, dated 2026 β€” periodt, go alter some servers πŸ’œπŸŒΈ

πŸ“¦ where this page comes from