ALTER SERVER β change the definition of a foreign server
| Use Case | Command | Description |
|---|---|---|
| Change server version | ALTER SERVER name VERSION 'new_version' | Update the version string of the foreign server. |
| Add connection options | ALTER SERVER name OPTIONS (ADD option 'value') | Add new options to the server. |
| Set an option | ALTER SERVER name OPTIONS (SET option 'value') | Modify an existing optionβs value. |
| Drop an option | ALTER SERVER name OPTIONS (DROP option) | Remove an option from the server. |
| Change owner | ALTER SERVER name OWNER TO new_owner | Transfer ownership of the server. |
| Rename server | ALTER SERVER name RENAME TO new_name | Rename the foreign server. |
| Example: add connection options | ALTER SERVER foo OPTIONS (host 'foo', dbname 'foodb'); | Add host and dbname options to server foo. |
| Example: change version and host | ALTER SERVER foo VERSION '8.4' OPTIONS (SET host 'baz'); | Update version to 8.4 and set host to 'baz'. |
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
π§ ALTER SERVER changes the definition of a foreign server. The first form changes the server version string or the generic options of the server (at least one clause is required). The second form changes the owner of the server.
π To alter the server you must be the owner of the server. Additionally 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. (π¦Έ Note that superusers satisfy all these criteria automatically.)
π Alter server foo, add connection options:
ALTER SERVER foo OPTIONS (host 'foo', dbname 'foodb');
π Alter server foo, change version, and change the host option:
ALTER SERVER foo VERSION '8.4' OPTIONS (SET host 'baz');
π ALTER SERVER conforms to ISO/IEC 9075-9 (SQL/MED). The OWNER TO and RENAME forms are PostgreSQL extensions.
π§ CREATE SERVER(7)βποΈ DROP SERVER(7)
π PostgreSQL 14.23 β 2026 β ALTER SERVER(7)
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 20:41 @2600:1f28:365:80b0:b91e:58eb:6587:15c8
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format