ALTER_EXTENSION(7pg15)

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

πŸ’… ALTER EXTENSION

okay bestie, welcome to the ALTER EXTENSION page from the PostgreSQL 15.19 docs β€” this is the PostgreSQL 15 corner of the manual, and this command is literally the glow-up button for an installed extension ✨


✨ NAME ✨

ALTER_EXTENSION β€” change the definition of an extension. that's it, that's the whole vibe. πŸŽ€


🌸 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 πŸ¦‹

so ALTER EXTENSION changes the definition of an installed extension β€” think of it as editing the extension's whole little lore after it's already been installed. there are several subforms, and they are giving very different energies πŸ’–

πŸ’« UPDATE

this form 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 update, no slay, periodt.

πŸ’« SET SCHEMA

this form moves the extension's objects into another schema. the extension has to be relocatable for this command to succeed β€” if it's not relocatable, this one's not gonna work, and that's just the truth 😭

πŸ’« ADD member_object

this form 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; notably, it can only be dropped by dropping the extension. yes bestie, the extension takes custody 🫢

πŸ’« DROP member_object

this form removes a member object from the extension. it's mainly useful in extension update scripts. important: the object is not dropped, only disassociated from the extension. it's giving "we're not deleting you, we're just no longer associated" πŸ’€

see Section 38.17 for more information about these operations.

you must own the extension to use ALTER EXTENSION. the ADD/DROP forms require ownership of the added/dropped object as well. so yeah, ownership check on top of ownership check β€” the security guard knows you by name at this point πŸ‘‘


πŸŽ€ 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 not specified, ALTER EXTENSION UPDATE attempts to update to whatever is shown as the default version in the extension's control file. default behavior said "i'll just pick for you" πŸ’…
  • 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 yes, you can absolutely use the full government name with the schema in front 🌈
  • 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 is sufficient to list the IN, INOUT, and VARIADIC arguments. OUT is literally there but not invited to the identity check πŸ™ˆ
  • 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. names are just vibes here, the types are the main character πŸ”₯
  • 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. do not leave it blank, do not leave it on read β€” write NONE for the missing side 😌
  • PROCEDURAL β€” this is a noise word. literally just noise, nothing to see here, no notes πŸ’€
  • 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, an extension command that is itself a PostgreSQL extension β€” the recursion is lowkey iconic πŸŒ€


⭐ SEE ALSO ⭐


bestie note: this one owns the extension, owns the object for ADD/DROP, and does not drop the object on DROP member_object β€” it just disassociates it. do not confuse "removed from the extension" with "deleted from existence." those are different things and one of them is way more dramatic 😭

and that's the page, bestie β€” brought to you by the PostgreSQL 15.19 documentation, dated 2026, and filed under ALTER EXTENSION(7) πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from