ALTER_ROUTINE(7pg15)
π NAME π
okay so bestie, welcome to the ALTER_ROUTINE(7) page β manual name folded in right at the top, as promised β and the whole point is literally: ALTER_ROUTINE changes the definition of a routine. that's the vibe. π
β¨ SYNOPSIS β¨
here's the exact shape of it, no cap:
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_ROLE | 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
where action is one of:
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
and the action menu is giving very much βpick your fighter,β bestie:
IMMUTABLE|STABLE|VOLATILEβ the volatility trio, exactly as written π«Ά[ NOT ] LEAKPROOFβ yes, theNOTis optional and it is invited[ EXTERNAL ] SECURITY INVOKER|[ EXTERNAL ] SECURITY DEFINERβ both security options, both with optionalEXTERNALPARALLEL { UNSAFE | RESTRICTED | SAFE }β the parallel pickerCOST execution_costβ the cost slotROWS result_rowsβ the rows slotSET configuration_parameter { TO | = } { value | DEFAULT }β set a config parameter to a value orDEFAULTSET configuration_parameter FROM CURRENTβ set itFROM CURRENTRESET configuration_parameterβ reset one config parameterRESET ALLβ reset all of them, periodt
π« DESCRIPTION π«
ALTER ROUTINE changes the definition of a routine, and a routine can be an aggregate function, a normal function, or a procedure β all three are welcome in this group chat. π
for the description of the parameters, 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 sister pages and they have the lore. β¨
πΈ EXAMPLES πΈ
say you wanna rename the routine foo for type integer to foobar β here's the move:
ALTER ROUTINE foo(integer) RENAME TO foobar;
this command will work independent of whether foo is an aggregate, function, or procedure. iconic, honestly β it does not need foo to pick a lane first. π
π¦ COMPATIBILITY π¦
this statement is partially compatible with the ALTER ROUTINE statement in the SQL standard. for more details, peek under ALTER FUNCTION (ALTER_FUNCTION(7)) and ALTER PROCEDURE (ALTER_PROCEDURE(7)).
and the part where routine names can refer to aggregate functions? that's a PostgreSQL extension. slay, but also noted. π
π SEE ALSO π
ALTER AGGREGATE(ALTER_AGGREGATE(7)) β aggregate-function business lives hereALTER FUNCTION(ALTER_FUNCTION(7)) β normal-function business lives hereALTER PROCEDURE(ALTER_PROCEDURE(7)) β procedure business lives hereDROP ROUTINE(DROP_ROUTINE(7)) β the dropping page, different vibe
also, bestie, note that there is no CREATE ROUTINE command. not me looking for it either. π
this page was brought to you by PostgreSQL 15.19, dated 2026 β slay, and happy altering π
π¦ 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