ALTER_FOREIGN_DATA_WRAPPER(7pg17)

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

πŸ’… ALTER_FOREIGN_DATA_WRAPPER πŸ’…

okay bestie, so this is a page straight out of the PostgreSQL 17.11 Documentation, and it's all about ALTER_FOREIGN_DATA_WRAPPER β€” the glow-up command for your foreign-data wrappers ✨


🌸 NAME 🌸

ALTER_FOREIGN_DATA_WRAPPER β€” change the definition of a foreign-data wrapper πŸ¦‹


✨ 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 literally just 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 no cap, at least one clause is required or it's not doing anything for you 🫢

The second form changes the owner of the foreign-data wrapper, main character energy πŸ‘‘

⚠️ okay important: only superusers can alter foreign-data wrappers. and additionally, only superusers can own foreign-data wrappers. not me gatekeeping but fr fr πŸ’€

πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of an existing foreign-data wrapper. yep, it has to already exist 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, bye πŸ‘‹
🚨 note that foreign tables that use a foreign-data wrapper with no handler cannot be accessed. like, at all. dead πŸ’€
  • VALIDATOR validator_function β€” sets a shiny new validator function for the foreign-data wrapper 🌈
πŸ™ˆ note that it's 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. and PostgreSQL does not check for this. it's up to you to make sure those options are correct before using the modified foreign-data wrapper, iykyk. However, 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. iconic, no notes πŸ’…
  • OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] ) β€” change options for the foreign-data wrapper. ADD, SET, and DROP specify the action to be performed, and ADD is assumed if no operation is explicitly specified. also 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. rebrand era πŸ¦‹

πŸ”₯ EXAMPLES πŸ”₯

change a foreign-data wrapper dbi, add option foo, drop bar:

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;

🌈 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. special little extras, periodt ✨


πŸ‘€ SEE ALSO πŸ‘€


and that's the tea bestie πŸ“ this whole thing is from PostgreSQL 17.11, dated 2026, filed under ALTER FOR...A WRAPPER(7) β€” slay, go alter some wrappers, ily πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from