ALTER_EXTENSION(7pg17)

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

πŸ’… ALTER EXTENSION β€” bestie edition ✨

okay so this is the ALTER EXTENSION page from the PostgreSQL 17.11 Documentation, and honestly? It's giving "glow-up for your extensions" energy. They're literally installed already, and now we're out here changing their whole definition. Obsessed. πŸŽ€


✨ SYNOPSIS ✨

ALTER EXTENSION name UPDATE [ TO new_version ]
ALTER EXTENSION name SET SCHEMA new_schema
ALTER EXTENSION name ADD member_object
ALTER EXTENSION name DROP member_object

and like, member_object is all of this (yes, all of it, no skipping):

  ACCESS METHOD object_name |
  AGGREGATE aggregate_name ( aggregate_signature ) |
  CAST (source_type AS target_type) |
  COLLATION object_name |
  CONVERSION object_name |
  DOMAIN object_name |
  EVENT TRIGGER object_name |
  FOREIGN DATA WRAPPER object_name |
  FOREIGN TABLE object_name |
  FUNCTION function_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
  MATERIALIZED VIEW object_name |
  OPERATOR operator_name (left_type, right_type) |
  OPERATOR CLASS object_name USING index_method |
  OPERATOR FAMILY object_name USING index_method |
  [ PROCEDURAL ] LANGUAGE object_name |
  PROCEDURE procedure_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
  ROUTINE routine_name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |
  SCHEMA object_name |
  SEQUENCE object_name |
  SERVER object_name |
  TABLE object_name |
  TEXT SEARCH CONFIGURATION object_name |
  TEXT SEARCH DICTIONARY object_name |
  TEXT SEARCH PARSER object_name |
  TEXT SEARCH TEMPLATE object_name |
  TRANSFORM FOR type_name LANGUAGE lang_name |
  TYPE object_name |
  VIEW object_name

and aggregate_signature is this whole situation:

* |
[ argmode ] [ argname ] argtype [ , ... ] |
[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]

πŸ’– DESCRIPTION πŸ’–

ALTER EXTENSION changes the definition of an installed extension. It's got several subforms and each one is a whole vibe:

  • UPDATE β€” this one updates the extension to a newer version ✨. The extension has to supply a suitable update script (or, like, a whole series of scripts) that can modify the currently-installed version into the requested version. No script, no slay.
  • SET SCHEMA β€” this form moves the extension's objects into another schema. For this command to succeed, the extension has to be relocatable β€” that's the vibe check it has to pass. πŸ¦‹
  • ADD member_object β€” this one adds an existing object to the extension. It's mainly useful in extension update scripts. The object will subsequently be treated as a member of the extension; and notably, it can only be dropped by dropping the extension. Like, once it's in the group chat, it's in the group chat. 😭
  • DROP member_object β€” removes a member object from the extension. Also mainly useful in extension update scripts. The object is not dropped, only disassociated from the extension. So it still exists, it's just not part of the ensemble anymore. πŸ’…

See Section 36.17 for more information about these operations β€” iykyk, go read it.

You must own the extension to use ALTER EXTENSION. And the ADD/DROP forms require ownership of the added/dropped object as well. So yeah, possession is the whole thing here. πŸ‘‘


🌸 PARAMETERS 🌸

  • name β€” the name of an installed extension.
  • new_version β€” the desired new version of the extension. You can write this as either an identifier or a string literal. If you don't specify it, ALTER EXTENSION UPDATE attempts to update to whatever is shown as the default version in the extension's control file. (Default behavior said what it said.)
  • new_schema β€” the new schema for the extension.
  • object_name, aggregate_name, function_name, operator_name, procedure_name, routine_name β€” the name of an object to be added to or removed from the extension. Names of tables, aggregates, domains, foreign tables, functions, operators, operator classes, operator families, procedures, routines, sequences, text search objects, types, and views can be schema-qualified. ✨
  • source_type β€” the name of the source data type of the cast.
  • target_type β€” the name of the target data type of the cast.
  • argmode β€” the mode of a function, procedure, or aggregate argument: IN, OUT, INOUT, or VARIADIC. If you omit it, the default is IN. Heads up bestie: ALTER EXTENSION does not actually pay any attention to OUT arguments, since only the input arguments are needed to determine the function's identity. So it's sufficient to list the IN, INOUT, and VARIADIC arguments. Don't waste your time listing the OUT ones, she's not reading them. πŸ™ˆ
  • argname β€” the name of a function, procedure, or aggregate argument. And again: ALTER EXTENSION does not actually pay any attention to argument names, since only the argument data types are needed to determine the function's identity. Names? Not the moment. πŸ’€
  • argtype β€” the data type of a function, procedure, or aggregate argument.
  • left_type, right_type β€” the data type(s) of the operator's arguments (optionally schema-qualified). Write NONE for the missing argument of a prefix operator. Missing argument found ✨
  • PROCEDURAL β€” this is a noise word. That's it. That's the whole description. It's giving filler episode. 🫢
  • type_name β€” the name of the data type of the transform.
  • lang_name β€” the name of the language of the transform.

πŸ¦‹ EXAMPLES πŸ¦‹

To update the hstore extension to version 2.0:

ALTER EXTENSION hstore UPDATE TO '2.0';

To change the schema of the hstore extension to utils:

ALTER EXTENSION hstore SET SCHEMA utils;

To add an existing function to the hstore extension:

ALTER EXTENSION hstore ADD FUNCTION populate_record(anyelement, hstore);

three examples, three slays, no notes. πŸ”₯


🌈 COMPATIBILITY 🌈

ALTER EXTENSION is a PostgreSQL extension. (Very "I'm not like other commands" of it, honestly.)


⭐ SEE ALSO ⭐


ngl the whole page boils down to: own the extension, own the object, and don't forget the update script. periodt. πŸ’œ

kisses and good vibes from the PostgreSQL 17.11 docs, dated 2026 β€” that's the ALTER EXTENSION(7) page, wrapped with love πŸ§šβ€β™€οΈπŸ’–

πŸ“¦ where this page comes from