ALTER_SERVER(7pg13)

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

πŸ’… ALTER SERVER (7pg13) β€” the glow-up your foreign server deserves ✨

Okay so like, this is the ALTER SERVER page from the PostgreSQL 13.23 Documentation bestie. It's literally the manual for changing up a foreign server's whole situation. Periodt. πŸŽ€


🌸 NAME 🌸

ALTER_SERVER β€” change the definition of a foreign server, no cap πŸ’–


✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So ALTER SERVER does exactly what it says on the tin bestie β€” it changes the definition of a foreign server. πŸ’…

The first form changes the server version string or the generic options of the server (and like, you need at least one clause β€” you can't just slide in with nothing, that's not the vibe). 🫢

The second form changes the owner of the server. Main character ownership energy.

⚠️ Okay so listen: to alter the server you must be the owner of the server. And 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. (Not me listing three whole requirements 😭 β€” but note that superusers satisfy all these criteria automatically, so they're chilling.) πŸ‘‘

πŸ’œ PARAMETERS πŸ’œ

  • name β€” the name of an existing server. Like, it's gotta already exist fr fr. πŸ“
  • new_version β€” new server version. Fresh version, new era. ✨
  • OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] ) β€” change options for the server. ADD, SET, and DROP specify the action to be performed. If you don't explicitly specify an operation, ADD is assumed (it's giving default behavior 😌). Option names must be unique β€” no gatekeeping the same name twice β€” and names and values are also validated using the server's foreign-data wrapper library. Iconic validation moment. πŸ’―
  • new_owner β€” the user name of the new owner of the foreign server. Handing over the crown. πŸ‘‘
  • new_name β€” the new name for the foreign server. Rebrand era. πŸ¦‹

πŸ”₯ EXAMPLES πŸ”₯

Alter server foo, add connection options β€” watch her slay:

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

Alter server foo, change version, change host option β€” the glow-up continues:

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

🌈 COMPATIBILITY 🌈

ALTER SERVER conforms to ISO/IEC 9075-9 (SQL/MED). Respectfully, standards queen. πŸ’…

But lowkey β€” the OWNER TO and RENAME forms are PostgreSQL extensions, so don't come for standards compliance when those two are doing their own thing. 😌


πŸ‘€ SEE ALSO πŸ‘€

  • CREATE SERVER (CREATE_SERVER(7)) β€” for when you're starting fresh, bestie
  • DROP SERVER (DROP_SERVER(7)) β€” for when it's time to say bye πŸ‘‹

Alright that's the whole thing, no notes. πŸ’– This has been the ALTER SERVER(7) page, brought to you by PostgreSQL 13.23 β€” yes, 13.23, that's the version, dated 2025, and honestly? She ate. Periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from