ALTER_EXTENSION(7)

๐Ÿ’… ALTER EXTENSION ๐Ÿ’…

okay bestie, so you know how extensions are like little add-on packs for your database? this is the page that tells you how to change them โ€” bump the version, move them to a new schema, adopt an object, kick an object out. it's in the PostgreSQL 18.6 docs, it lives in manual section 7, and honestly? it's giving "let me rearrange my whole room at 2am" energy. ๐ŸŽ€


โœจ NAME โœจ

ALTER_EXTENSION โ€” change the definition of an extension


๐Ÿฆ‹ 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

where member_object is:

  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:

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

๐ŸŒธ DESCRIPTION ๐ŸŒธ

ALTER EXTENSION changes the definition of an installed extension. it's got a few subforms and each one is its own little main character moment:

  • UPDATE โ€” this one updates the extension to a newer version. the extension has to supply a suitable update script (or series of scripts) that can modify the currently-installed version into the requested version. no script, no glow-up. ๐Ÿ’…
  • SET SCHEMA โ€” moves the extension's objects into another schema. for this to work, the extension has to be relocatable. if it's not relocatable, this command will simply not succeed, periodt.
  • ADD member_object โ€” adds an existing object to the extension. this is mainly useful in extension update scripts. after this, the object is treated as a member of the extension, and notably it can only be dropped by dropping the extension. it's adopted fr fr, no take-backsies. ๐Ÿซถ
  • DROP member_object โ€” removes a member object from the extension. also mainly useful in extension update scripts. important: the object itself is not dropped, it's only disassociated from the extension. it's not gone, it just left the group chat. ๐Ÿ˜ญ

see Section 36.17 for more information about these operations.

๐Ÿ‘‘ you must own the extension to use ALTER EXTENSION. and the ADD/DROP forms require ownership of the added/dropped object as well. so likeโ€ฆ you gotta actually own it. both of them. yes, both.

๐ŸŽ€ PARAMETERS ๐ŸŽ€

  • name โ€” the name of an installed extension.
  • new_version โ€” the desired new version of the extension. this can be written 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. it just picks for you, bestie.
  • 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. so you can slap a schema on the front if you want to be specific. โœจ
  • 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 omitted, the default is IN. note that 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. OUT is just there vibing. ๐Ÿ™ˆ
  • argname โ€” the name of a function, procedure, or aggregate argument. note that 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. it literally does not care what you named it. ๐Ÿ’€
  • 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.
  • PROCEDURAL โ€” this is a noise word. that's it. that's the whole description. iconic honestly. ๐ŸŽ€
  • 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);

๐Ÿ’œ COMPATIBILITY ๐Ÿ’œ

ALTER EXTENSION is a PostgreSQL extension.

yes. the command about extensions is itself an extension. we love a self-referential moment. ๐Ÿงš

โญ SEE ALSO โญ


and that's the whole page, bestie! ๐Ÿฆ‹ this was PostgreSQL 18.6 documentation, dated 2026 โ€” go forth and rearrange your extensions responsibly. mwah. ๐Ÿ’–๐Ÿ‘‘

PostgreSQL 18.6 ยท 2026 ยท ALTER EXTENSION(7) โœจ