ALTER_FOREIGN_DATA_WRAPPER(7pg16)
π ALTER_FOREIGN_DATA_WRAPPER π
okay so bestie, this is the ALTER_FOREIGN_DATA_WRAPPER(7) page from the PostgreSQL 16 docs β yes, the PostgreSQL 16.15 documentation, that's the one. it's all about changing up a foreign-data wrapper's whole definition. let's get into it π
β¨ SYNOPSIS β¨
like, here's the whole shape of it:
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 πΈ
ALTER FOREIGN DATA WRAPPER changes the definition of a foreign-data wrapper. that's the whole vibe. π«
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 send it empty and expect anything to happen. the second form changes the owner of the foreign-data wrapper.
π¨ only superusers can alter foreign-data wrappers. and yes, additionally, only superusers can own foreign-data wrappers. it's giving exclusive club, no cap π
π¦ PARAMETERS π¦
nameβ the name of an existing foreign-data wrapper. gotta already exist, we're not creating anything here.HANDLER handler_functionβ specifies a new handler function for the foreign-data wrapper.NO HANDLERβ this is used to specify that the foreign-data wrapper should no longer have a handler function.
β οΈ 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 unless you mean it π
VALIDATOR validator_functionβ specifies a new validator function for the foreign-data wrapper.
β οΈ note that 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 matters β any options specified in this ALTER FOREIGN DATA WRAPPER command will be checked using the new validator. so the new stuff gets the vibe check, the old stuff does not π
NO VALIDATORβ this is used to specify that the foreign-data wrapper should no longer have a validator function.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. option names must be unique; names and values are also validated using the foreign data wrapper's validator function, if any. periodt. π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 how clean this is:
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;
ate, no crumbs π
β 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 like, mostly standard, a lil extra on top πββοΈ
π SEE ALSO π
CREATE FOREIGN DATA WRAPPER(CREATE_FOREIGN_DATA_WRAPPER(7))DROP FOREIGN DATA WRAPPER(DROP_FOREIGN_DATA_WRAPPER(7))
and that's the page, bestie π«Ά this was PostgreSQL 16.15 documentation, dated 2026, from the ALTER_FOREIGN_DATA_WRAPPER(7) manual page β go forth and alter those wrappers responsibly πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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