ALTER_FOREIGN_DATA_WRAPPER(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

โœจ 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, and DROP specify the action to be performed. ADD is 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 ๐Ÿ‘‘


๐Ÿ’– 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