ALTER_ROUTINE(7pg13)
π ALTER_ROUTINE β changing the definition of a routine
okay bestie, so this is the ALTER ROUTINE page from the PostgreSQL 13.23 docs, and it's genuinely one of the most "one size fits all" commands out there. Let's get into it β¨
β¨ NAME β¨
ALTER_ROUTINE β change the definition of a routine
π SYNOPSIS π
like, here's the whole vibe, verbatim:
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
action [ ... ] [ RESTRICT ]
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
RENAME TO new_name
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
SET SCHEMA new_schema
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
[ NO ] DEPENDS ON EXTENSION extension_name
and action is one of these icons right here:
IMMUTABLE | STABLE | VOLATILE
[ NOT ] LEAKPROOF
[ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
PARALLEL { UNSAFE | RESTRICTED | SAFE }
COST execution_cost
ROWS result_rows
SET configuration_parameter { TO | = } { value | DEFAULT }
SET configuration_parameter FROM CURRENT
RESET configuration_parameter
RESET ALL
π¦ DESCRIPTION π¦
so ALTER ROUTINE changes the definition of a routine, and a routine can be any of these three besties:
- an aggregate function
- a normal function
- a procedure
that's the whole point β it's the umbrella command that doesn't care which one you actually have π
for the actual description of the parameters, plus more examples and further details, go look under ALTER AGGREGATE (ALTER_AGGREGATE(7)), ALTER FUNCTION (ALTER_FUNCTION(7)), and ALTER PROCEDURE (ALTER_PROCEDURE(7)). they're the ones with the lore β¨
πΈ EXAMPLES πΈ
say you wanna rename the routine foo for type integer to foobar. iconic. do this:
ALTER ROUTINE foo(integer) RENAME TO foobar;
and the gorgeous part? this command will work independent of whether foo is an aggregate, function, or procedure. it literally does not care. main character energy fr fr π
π COMPATIBILITY π
this statement is partially compatible with the ALTER ROUTINE statement in the SQL standard. partial! so not a full slay. check under ALTER FUNCTION (ALTER_FUNCTION(7)) and ALTER PROCEDURE (ALTER_PROCEDURE(7)) for more details π«Ά
also, allowing routine names to refer to aggregate functions is a PostgreSQL extension. iykyk π
β SEE ALSO β
ALTER AGGREGATE(ALTER_AGGREGATE(7))ALTER FUNCTION(ALTER_FUNCTION(7))ALTER PROCEDURE(ALTER_PROCEDURE(7))DROP ROUTINE(DROP_ROUTINE(7))
heads up bestie β note that there is no CREATE ROUTINE command. don't go looking for it, it's not there π
and that's the page!! π this was the PostgreSQL 13.23 documentation, dated 2025 β go off and alter some routines, you've got this ππ¦β¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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