ALTER_FOREIGN_DATA_WRAPPER(7pg14)

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

πŸ’– 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, and DROP specify the action to be performed. ADD is 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 ⭐

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