ALTER_FOREIGN_DATA_WRAPPER(7pg14)
π ALTER_FOREIGN_DATA_WRAPPER π
okay so this is the ALTER FOREIGN DATA WRAPPER page from the PostgreSQL 14.24 docs (manual section 7, bestie β we stan a numbered section) and it's literally all about changing the definition of a foreign-data wrapper. yes, that whole thing. let's get into it π«Ά
β¨ 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
like three whole forms, pick your fighter π
πΈ DESCRIPTION πΈ
ALTER FOREIGN DATA WRAPPER changes the definition of a foreign-data wrapper. that's the whole assignment, no cap.
the first form of the command changes the support functions or the generic options of the foreign-data wrapper β and heads up, at least one clause is required there, you can't just say the command and dip π.
the second form changes the owner of the foreign-data wrapper.
and now the gatekeeping part: only superusers can alter foreign-data wrappers. additionally, only superusers can own foreign-data wrappers. so if that's not youβ¦ it's giving not-your-main-character-moment π
π PARAMETERS π
nameβ the name of an existing foreign-data wrapper. gotta exist, that's the vibe check.HANDLER handler_functionβ specifies a new handler function for the foreign-data wrapper. new handler, who dis β¨NO HANDLERβ used to specify that the foreign-data wrapper should no longer have a handler function.
lowkey important: note that foreign tables that use a foreign-data wrapper with no handler cannot be accessed. like, at all. so maybe don't do this casually bestie π
VALIDATOR validator_functionβ specifies a new validator function for the foreign-data wrapper.
okay so this one's a whole paragraph and you need to hear it: 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 is the slay part β any options specified in this ALTER FOREIGN DATA WRAPPER command will be checked using the new validator. so the new stuff gets validated, the old stuff is on you π«΅
NO VALIDATORβ used to specify that the foreign-data wrapper should no longer have a validator function. bye validation πOPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )β change options for the foreign-data wrapper.ADD,SET, andDROPspecify the action to be performed.ADDis assumed if no operation is explicitly specified (default behaviour, 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_nameβ the new name for the foreign-data wrapper.
π₯ EXAMPLES π₯
change a foreign-data wrapper dbi, add option foo, drop bar β look at her go:
ALTER FOREIGN DATA WRAPPER dbi OPTIONS (ADD foo '1', DROP bar);
change the foreign-data wrapper dbi validator to bob.myvalidator:
ALTER FOREIGN DATA WRAPPER dbi VALIDATOR bob.myvalidator;
both of these ate, fr fr π
π 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. standard-adjacent but not fully standard, iykyk πΈ
β SEE ALSO β
CREATE FOREIGN DATA WRAPPER(CREATE_FOREIGN_DATA_WRAPPER(7))DROP FOREIGN DATA WRAPPER(DROP_FOREIGN_DATA_WRAPPER(7))
go read those next, they're the siblings and they're also iconic π
and that's the page!! π¦ this was PostgreSQL 14.24, dated 2026, manual section ALTER FOR...A WRAPPER(7) β mwah, thanks for reading, ily, now go alter responsibly ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms