ALTER_ROUTINE(7pg17)

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

πŸ’… ALTER ROUTINE β€” the glow-up command for your routines (PostgreSQL 17.11 docs, bestie) ✨

🌸 NAME 🌸

ALTER_ROUTINE β€” change the definition of a routine. That's it, that's the vibe. πŸŽ€


✨ SYNOPSIS ✨

Okay so here's the whole menu, no cap β€” copy it exactly, don't @ me:

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

and action is one of these icons πŸ’…:

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 πŸ¦‹

ALTER ROUTINE changes the definition of a routine β€” and a routine can be an aggregate function, a normal function, or a procedure. Like, it's the umbrella term, the main character of callables, iykyk. 🌈

For the actual tea on the parameters, more examples, and further details, go see ALTER AGGREGATE (ALTER_AGGREGATE(7)), ALTER FUNCTION (ALTER_FUNCTION(7)), and ALTER PROCEDURE (ALTER_PROCEDURE(7)). They've got the lore. πŸ“š


πŸ“ EXAMPLES πŸ“

Wanna rename the routine foo for type integer to foobar? Slay, do this:

ALTER ROUTINE foo(integer) RENAME TO foobar;

And the iconic part? πŸ’« This command will work independent of whether foo is an aggregate, function, or procedure. It genuinely does not care. Queen behavior. πŸ‘‘


πŸ’œ COMPATIBILITY πŸ’œ

This statement is partially compatible with the ALTER ROUTINE statement in the SQL standard β€” so like, it's mostly matching the group chat, but not fully fr fr. See under ALTER FUNCTION (ALTER_FUNCTION(7)) and ALTER PROCEDURE (ALTER_PROCEDURE(7)) for more details. πŸ“–

Also, letting routine names refer to aggregate functions is a PostgreSQL extension. So that's a Postgres-original, bestie. 🫢


πŸŽ€ SEE ALSO πŸŽ€

Heads up bestie πŸ’€ β€” note that there is no CREATE ROUTINE command. Like, it does not exist. Don't go looking for it, she's not coming to the party. πŸ™ˆ

and that's the whole page, mwah πŸ’‹ β€” this was PostgreSQL 17.11, dated 2026, ALTER ROUTINE(7), signing off πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from