ALTER_ROUTINE(7pg16)

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

✨ NAME ✨

okay bestie, welcome to ALTER_ROUTINE(7) from the PostgreSQL 16.15 docs πŸ’… this is the page for ALTER_ROUTINE β€” aka changing the definition of a routine. periodt.

πŸŽ€ 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 πŸ’–

ALTER ROUTINE changes the definition of a routine β€” and a routine here can be an aggregate function, a normal function, or a procedure. like, it's the main-character umbrella term for all three 🫢

for the description of the parameters, more examples, and further details, see under ALTER AGGREGATE (ALTER_AGGREGATE(7)), ALTER FUNCTION (ALTER_FUNCTION(7)), and ALTER PROCEDURE (ALTER_PROCEDURE(7)). iykyk πŸ’«


🌸 EXAMPLES 🌸

to rename the routine foo for type integer to foobar:

ALTER ROUTINE foo(integer) RENAME TO foobar;

this command will work independent of whether foo is an aggregate, function, or procedure. no cap, it's giving equal-opportunity rename energy πŸ’…


πŸ¦‹ COMPATIBILITY πŸ¦‹

this statement is partially compatible with the ALTER ROUTINE statement in the SQL standard. see under ALTER FUNCTION (ALTER_FUNCTION(7)) and ALTER PROCEDURE (ALTER_PROCEDURE(7)) for more details.

allowing routine names to refer to aggregate functions is a PostgreSQL extension ✨


πŸ”₯ SEE ALSO πŸ”₯

πŸ’€ note that there is no CREATE ROUTINE command. not me checking twice, but bestie, it's literally not a thing πŸ™ˆ

source/version: PostgreSQL 16.15 β€’ date: 2026 β€’ bye bestie, go alter those routines πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from