ALTER FUNCTION
ALTER FUNCTION changes the definition of a function.
Supported syntax
ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] RENAME TO new_name ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER } ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] SET SCHEMA new_schema
Description
ALTER FUNCTION changes the definition of an existing function.
You must own the function to use ALTER FUNCTION. To change a function's schema,
you must also have CREATE privilege on the new schema. To alter the owner, you must be
a member of the new owning role, and that role must have CREATE
privilege on the function's schema.
RENAME TO-
Changes the name of the function.
OWNER TO-
Changes the owner of the function to the specified user.
SET SCHEMA-
Moves the function into another schema.
Parameters
name-
The name (optionally schema-qualified) of an existing function to alter.
argmode-
The mode of an argument:
IN,OUT,INOUT, orVARIADIC. If omitted, the default isIN. The function uses only the input arguments for identification, so list only theIN,INOUT, andVARIADICarguments. argname-
The name of an argument.
argtype-
The data type(s) of the function's arguments.
new_name-
The new name for the function.
new_owner-
The new owner of the function.
new_schema-
The new schema for the function.
Considerations
To change other attributes than those listed above, use CREATE OR REPLACE FUNCTION.
For more information, see CREATE FUNCTION.
To add, change, or remove a comment on a function, use the separate COMMENT ON
FUNCTION command.
Examples
Rename the function add (which takes two integer arguments) to
sum_two:
ALTER FUNCTION add(integer, integer) RENAME TO sum_two;
Change the owner of the function add to the current user:
ALTER FUNCTION add(integer, integer) OWNER TO CURRENT_USER;
Move the function add into the schema utils:
ALTER FUNCTION add(integer, integer) SET SCHEMA utils;
Compatibility
Aurora DSQL supports the RENAME TO, OWNER TO, and
SET SCHEMA forms of the PostgreSQL ALTER FUNCTION statement. The
other forms available in PostgreSQL are not supported.