ALTER_EXTENSION(7pg18)
๐ 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 useALTER EXTENSION. and theADD/DROPforms 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 UPDATEattempts 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_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 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, 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's sufficient to list theIN,INOUT, andVARIADICarguments.OUTis just there vibing. ๐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. it literally does not care what you named it. ๐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.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 โญ
CREATE EXTENSION(CREATE_EXTENSION(7))DROP EXTENSION(DROP_EXTENSION(7))
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) โจ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms