ALTER_EXTENSION(7pg15)
π 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 UPDATEattempts 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_nameaggregate_namefunction_nameoperator_nameprocedure_nameroutine_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, orVARIADIC. if omitted, the default isIN. note thatALTER EXTENSIONdoes not actually pay any attention toOUTarguments, since only the input arguments are needed to determine the function's identity. so it is sufficient to list theIN,INOUT, andVARIADICarguments.OUTis literally there but not invited to the identity check πargnameβ the name of a function, procedure, or aggregate argument. note thatALTER EXTENSIONdoes 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_typeright_typeβ the data type(s) of the operator's arguments (optionally schema-qualified). writeNONEfor the missing argument of a prefix operator. do not leave it blank, do not leave it on read β writeNONEfor 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 β
CREATE EXTENSION(CREATE_EXTENSION(7))DROP EXTENSION(DROP_EXTENSION(7))
bestie note: this one owns the extension, owns the object forADD/DROP, and does not drop the object onDROP 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
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms