Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

ALTER FUNCTION

Name

ALTER FUNCTION -- change the definition of a function

Synopsis

ALTER FUNCTION name ( [ type [, ...] ] ) RENAME TO newname
ALTER FUNCTION name ( [ type [, ...] ] ) OWNER TO newowner

Description

ALTER FUNCTION changes the definition of a function.

Parameters

name

The name (optionally schema-qualified) of an existing function.

type

The data type of an argument of the function.

newname

The new name of the function.

newowner

The new owner of the function. To change the owner of a function, you must be a superuser. Note that if the function is marked SECURITY DEFINER, it will subsequently execute as the new owner.

Examples

To rename the function sqrt for type integer to square_root:

ALTER FUNCTION sqrt(integer) RENAME TO square_root;

To change the owner of the function sqrt for type integer to joe:

ALTER FUNCTION sqrt(integer) OWNER TO joe;

Compatibility

There is an ALTER FUNCTION statement in the SQL standard, but it does not provide the option to rename the function or change the owner.