ALTER_ROUTINE(7)
๐ 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 ๐
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. 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
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms