ALTER_FOREIGN_DATA_WRAPPER(7pg18)
โจ NAME โจ
ALTER_FOREIGN_DATA_WRAPPER โ bestie, this is the ALTER FOREIGN DATA WRAPPER page, and it's literally all about giving your foreign-data wrapper a whole new definition. Glow-up szn. ๐
๐ธ SYNOPSIS ๐ธ
ALTER FOREIGN DATA WRAPPER name
[ HANDLER handler_function | NO HANDLER ]
[ VALIDATOR validator_function | NO VALIDATOR ]
[ OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ]) ]
ALTER FOREIGN DATA WRAPPER name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER FOREIGN DATA WRAPPER name RENAME TO new_name
๐ฆ DESCRIPTION ๐ฆ
So ALTER FOREIGN DATA WRAPPER changes the definition of a foreign-data wrapper. That's the whole vibe. ๐
The first form of the command swaps out the support functions or the generic options of the foreign-data wrapper โ and heads up, you need at least one clause here, you can't just show up with nothing. The second form changes the owner of the foreign-data wrapper.
๐จ Okay so real talk: only superusers can alter foreign-data wrappers. And also โ only superusers can own foreign-data wrappers. That's the rule, no cap.
๐ PARAMETERS ๐
nameโ the name of a foreign-data wrapper that already exists. Not a made-up one, bestie. ๐HANDLER handler_functionโ gives the foreign-data wrapper a brand-new handler function. โจNO HANDLERโ says the foreign-data wrapper should no longer have a handler function, periodt.
โ ๏ธ Note that foreign tables that use a foreign-data wrapper with no handler cannot be accessed. Like, they're just sitting there. Unreachable. ๐
VALIDATOR validator_functionโ gives the foreign-data wrapper a new validator function. ๐
๐ญ Okay important: it is possible that pre-existing options of the foreign-data wrapper, or of dependent servers, user mappings, or foreign tables, are invalid according to the new validator. PostgreSQL does not check for this. It is up to the user to make sure that these options are correct before using the modified foreign-data wrapper. However โ and this part is cute โ any options specified in this ALTER FOREIGN DATA WRAPPER command will be checked using the new validator. ๐ซถ
NO VALIDATORโ says the foreign-data wrapper should no longer have a validator function.OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )โ changes options for the foreign-data wrapper.ADD,SET, andDROPspecify the action to be performed.ADDis assumed if no operation is explicitly specified (she's the default, iconic). Option names must be unique; names and values are also validated using the foreign data wrapper's validator function, if any. ๐new_ownerโ the user name of the new owner of the foreign-data wrapper. New main character energy. ๐new_nameโ the new name for the foreign-data wrapper.
๐ EXAMPLES ๐
Okay so say you want to change a foreign-data wrapper dbi, add option foo, and drop bar. You literally just:
ALTER FOREIGN DATA WRAPPER dbi OPTIONS (ADD foo '1', DROP bar);
And if you wanna change the foreign-data wrapper dbi validator to bob.myvalidator:
ALTER FOREIGN DATA WRAPPER dbi VALIDATOR bob.myvalidator;
Slay. Go off. ๐ฅ
๐ COMPATIBILITY ๐
ALTER FOREIGN DATA WRAPPER conforms to ISO/IEC 9075-9 (SQL/MED) โ except that the HANDLER, VALIDATOR, OWNER TO, and RENAME clauses are extensions. So basically, mostly standard, a lil extra. As she should be. โจ
๐ SEE ALSO ๐
CREATE FOREIGN DATA WRAPPER(CREATE_FOREIGN_DATA_WRAPPER(7))DROP FOREIGN DATA WRAPPER(DROP_FOREIGN_DATA_WRAPPER(7))
๐ That's the whole page, bestie! ๐
This one's straight outta PostgreSQL 18.6, dated 2026, and it's the ALTER FOR...A WRAPPER(7) page โ yeah, the title got cut off in the header, we don't talk about it ๐. Love u, go alter something responsibly (as a superuser, obviously). ๐๐ฆ๐ธ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms