ALTER_EXTENSION(7pg14)

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

πŸ’… ALTER EXTENSION πŸ’…

okay bestie, so you know that page ALTER EXTENSION(7) from the PostgreSQL 14.24 Documentation? yeah. that one. it's giving "I install extensions and I need to rearrange them" and honestly? iconic. let's get into it 🫢


✨ NAME ✨

ALTER_EXTENSION β€” change the definition of an extension. that's it. that's the whole vibe. lowkey powerful, highkey necessary πŸ’œ


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the whole shape of the thing, no cap, copy it exactly:

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 member_object is literally this whole list, every single one, don't skip:

  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 little icon right here πŸŽ€:

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

🌸 DESCRIPTION 🌸

so ALTER EXTENSION changes the definition of an installed extension. like, it's the glow-up command for extensions already on the scene. it comes in several subforms and honestly each one ate:

πŸ’– UPDATE

updates the extension to a newer version, periodt. the extension must supply a suitable update script (or a whole series of scripts) that can take the currently-installed version and morph it into the version you're asking for. no script, no slay. 😭

πŸ’– SET SCHEMA

moves the extension's objects into another schema. the catch? the extension has to be relocatable for this to succeed. if it's not relocatable, it's giving 🚫 and the command will not go through.

πŸ’– ADD member_object

adds an existing object into the extension. mainly useful in extension update scripts, iykyk. once it's added, the object is subsequently treated as a member of the extension β€” and notably, it can only be dropped by dropping the extension. that's the whole deal, no getting around it πŸ”₯

πŸ’– DROP member_object

removes a member object from the extension. again, mainly useful in extension update scripts. important: the object is not dropped, it's only disassociated from the extension. it's a soft launch. it's "we're not together anymore but you still exist" πŸ’€

see Section 38.17 for more info about these operations.

🫢 real talk: you must own the extension to use ALTER EXTENSION. and the ADD/DROP forms? those require ownership of the added/dropped object as well. no borrowing, no sharing.

🧚 PARAMETERS 🧚

  • name β€” the name of an installed extension. that's the one you're messing with.
  • new_version β€” the desired new version of the extension. can be written as either an identifier or a string literal, your call bestie. 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. surprise! it picks for you.
  • new_schema β€” the new schema for the extension. where it's moving to 🏑
  • 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. the 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 go ahead and qualify them πŸ’…
  • 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. heads up: 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 is sufficient to list the IN, INOUT, and VARIADIC arguments. skip the OUT ones, they're not being checked πŸ’€
  • 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. the names are just there vibing πŸ™ˆ
  • 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. yeah, NONE. capital letters, bestie ⭐
  • PROCEDURAL β€” this is a noise word. that's it. that's the whole description. it's a noise word πŸŽ€
  • type_name β€” the name of the data type of the transform.
  • lang_name β€” the name of the language of the transform.

πŸ”₯ EXAMPLES πŸ”₯

bestie these are the moments, fr fr.

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);

see? iconic behavior. all three. πŸ‘‘


🌈 COMPATIBILITY 🌈

ALTER EXTENSION is a PostgreSQL extension. like, it's ours. homegrown. main character energy only πŸ’œ


⭐ SEE ALSO ⭐


and that's the page bestie!! go forth and rearrange your extensions responsibly πŸ¦‹πŸŒΈπŸ’–

πŸŽ€ cute little sign-off: this whole vibe is from PostgreSQL 14.24, dated 2026, and lives at the top of the page as ALTER EXTENSION(7). mwah πŸ’‹
πŸ“¦ where this page comes from