HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/pgsql-14/share/man/man7/ALTER_ROUTINE.7
'\" t
.\"     Title: ALTER ROUTINE
.\"    Author: The PostgreSQL Global Development Group
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2025
.\"    Manual: PostgreSQL 14.18 Documentation
.\"    Source: PostgreSQL 14.18
.\"  Language: English
.\"
.TH "ALTER ROUTINE" "7" "2025" "PostgreSQL 14.18" "PostgreSQL 14.18 Documentation"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ALTER_ROUTINE \- change the definition of a routine
.SH "SYNOPSIS"
.sp
.nf
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
    \fIaction\fR [ \&.\&.\&. ] [ RESTRICT ]
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
    RENAME TO \fInew_name\fR
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
    OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
    SET SCHEMA \fInew_schema\fR
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
    [ NO ] DEPENDS ON EXTENSION \fIextension_name\fR

where \fIaction\fR is one of:

    IMMUTABLE | STABLE | VOLATILE
    [ NOT ] LEAKPROOF
    [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
    PARALLEL { UNSAFE | RESTRICTED | SAFE }
    COST \fIexecution_cost\fR
    ROWS \fIresult_rows\fR
    SET \fIconfiguration_parameter\fR { TO | = } { \fIvalue\fR | DEFAULT }
    SET \fIconfiguration_parameter\fR FROM CURRENT
    RESET \fIconfiguration_parameter\fR
    RESET ALL
.fi
.SH "DESCRIPTION"
.PP
\fBALTER ROUTINE\fR
changes the definition of a routine, which can be an aggregate function, a normal function, or a procedure\&. See under
ALTER AGGREGATE (\fBALTER_AGGREGATE\fR(7)),
ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), and
ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7))
for the description of the parameters, more examples, and further details\&.
.SH "EXAMPLES"
.PP
To rename the routine
foo
for type
integer
to
foobar:
.sp
.if n \{\
.RS 4
.\}
.nf
ALTER ROUTINE foo(integer) RENAME TO foobar;
.fi
.if n \{\
.RE
.\}
.sp
This command will work independent of whether
foo
is an aggregate, function, or procedure\&.
.SH "COMPATIBILITY"
.PP
This statement is partially compatible with the
\fBALTER ROUTINE\fR
statement in the SQL standard\&. See under
ALTER FUNCTION (\fBALTER_FUNCTION\fR(7))
and
ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7))
for more details\&. Allowing routine names to refer to aggregate functions is a
PostgreSQL
extension\&.
.SH "SEE ALSO"
ALTER AGGREGATE (\fBALTER_AGGREGATE\fR(7)), ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7)), DROP ROUTINE (\fBDROP_ROUTINE\fR(7))
.PP
Note that there is no
CREATE ROUTINE
command\&.