info > ALTER_ROUTINE(7)

๐Ÿ“› NAME

ALTER ROUTINE โ€” change the definition of a routine (aggregate, function, or procedure).

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ”„ Rename a routineALTER ROUTINE foo(integer) RENAME TO bar;Rename the routine with matching argument types.
๐Ÿ“ฆ Change ownerALTER ROUTINE foo(integer) OWNER TO alice;Transfer ownership of the routine.
๐Ÿ—‚๏ธ Move to a schemaALTER ROUTINE foo(integer) SET SCHEMA new_schema;Relocate the routine to another schema.
๐Ÿ”’ Security definerALTER ROUTINE foo(integer) SECURITY DEFINER;Execute with the privileges of the routine owner.
๐Ÿ“Š Set volatilityALTER ROUTINE foo(integer) IMMUTABLE;Label as IMMUTABLE, STABLE, or VOLATILE.
โš™๏ธ Change costALTER ROUTINE foo(integer) COST 100;Adjust estimated execution cost.
๐Ÿ“ˆ Estimated rowsALTER ROUTINE foo(integer) ROWS 1000;Set approximate number of rows returned by the routine.
๐Ÿงต Parallel safetyALTER ROUTINE foo(integer) PARALLEL SAFE;Control whether parallel execution is allowed.
๐Ÿ› ๏ธ ConfigurationALTER ROUTINE foo(integer) SET work_mem = '4MB';Set session-level parameters for the routine.
๐Ÿ”— Extension dependencyALTER ROUTINE foo(integer) DEPENDS ON EXTENSION ext;Mark routine as dependent (or NOT) on an extension.

๐Ÿ“‹ 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:

๐Ÿ“– DESCRIPTION

ALTER ROUTINE changes the definition of a routine, which can be an aggregate function, a normal function, or a procedure. See under ALTER AGGREGATE (7), ALTER FUNCTION (7), and ALTER PROCEDURE (7) for the description of the parameters, more examples, and further details.

๐Ÿ’ก 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.

๐Ÿ”„ COMPATIBILITY

This statement is partially compatible with the ALTER ROUTINE statement in the SQL standard. See under ALTER FUNCTION (7) and ALTER PROCEDURE (7) for more details. Allowing routine names to refer to aggregate functions is a PostgreSQL extension.

๐Ÿ“š SEE ALSO

ALTER AGGREGATE (7), ALTER FUNCTION (7), ALTER PROCEDURE (7), DROP ROUTINE (7)

Note that there is no CREATE ROUTINE command.

ALTER_ROUTINE(7)
๐Ÿ“› NAME ๐Ÿš€ Quick Reference ๐Ÿ“‹ SYNOPSIS ๐Ÿ“– DESCRIPTION ๐Ÿ’ก EXAMPLES ๐Ÿ”„ COMPATIBILITY ๐Ÿ“š SEE ALSO

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-24 03:45 @216.73.216.102
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!