ALTER_ROUTINE(7pg15)

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

πŸŽ€ 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, the NOT is optional and it is invited
  • [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER β€” both security options, both with optional EXTERNAL
  • PARALLEL { UNSAFE | RESTRICTED | SAFE } β€” the parallel picker
  • COST execution_cost β€” the cost slot
  • ROWS result_rows β€” the rows slot
  • SET configuration_parameter { TO | = } { value | DEFAULT } β€” set a config parameter to a value or DEFAULT
  • SET configuration_parameter FROM CURRENT β€” set it FROM CURRENT
  • RESET configuration_parameter β€” reset one config parameter
  • RESET 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 πŸŽ€

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