ALTER_ROUTINE(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’– ALTER ROUTINE ๐Ÿ’–

okay bestie, welcome to ALTER_ROUTINE(7) from the PostgreSQL 18.6 Documentation โ€” this is the page where we learn how to glow-up a routine that's already out there in the world. โœจ


๐ŸŒธ NAME ๐ŸŒธ

ALTER_ROUTINE โ€” change the definition of a routine


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

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

โœจ DESCRIPTION โœจ

so ALTER ROUTINE changes the definition of a routine. and bestie, a routine here is the umbrella term โ€” it can be an aggregate function, a normal function, or a procedure. it's giving "one command, three friend groups." ๐Ÿ’…

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)). the deets live there, this page is just the vibe-check entrance. ๐Ÿฆ‹


๐ŸŒˆ EXAMPLES ๐ŸŒˆ

want to rename the routine foo for type integer to foobar? say less:

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 does not care. it does not ask questions. it just slays. ๐Ÿ‘‘


๐Ÿ’œ COMPATIBILITY ๐Ÿ’œ

ngl, this statement is partially compatible with the ALTER ROUTINE statement in the SQL standard. if you want the whole breakdown, see under ALTER FUNCTION (ALTER_FUNCTION(7)) and ALTER PROCEDURE (ALTER_PROCEDURE(7)) for more details.

one thing that's PostgreSQL-only, no cap: allowing routine names to refer to aggregate functions is a PostgreSQL extension. ๐Ÿซถ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

๐Ÿ’€ heads up bestie: note that there is no CREATE ROUTINE command. i know. i know. we all wanted one. ๐Ÿ˜ญ

PostgreSQL 18.6 โ€ข 2026 โ€” that's the version and the date, babes, and this has been your girl walking you through ALTER ROUTINE(7). go rename something. respectfully. ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from