ALTER_ROUTINE(7pg17)
π 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 π
- 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. 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
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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