ALTER FUNCTION

Function

Modifies the attributes of a customized function.

Precautions

Only the owner of a function or a system administrator can run this statement. The user who wants to change the owner of a function must be a direct or indirect member of the new owning role. If a function involves operations on temporary tables, the ALTER FUNCTION cannot be used.

Syntax

Parameter Description

Examples

Alter the execution rule of function add to IMMUTABLE (that is, the same result is returned if the parameter remains unchanged):

1
ALTER FUNCTION func_add_sql2(INTEGER, INTEGER) IMMUTABLE;

Change the name of the add function to add_two_number.

1
ALTER FUNCTION func_add_sql2(INTEGER, INTEGER) RENAME TO add_two_number;

Change the name of the function add in tpcds to add_two_number, and prefix it with the original schema name.

1
ALTER FUNCTION tpcds.func_add_sql2(INTEGER, INTEGER) RENAME TO tpcds.add_two_number;

Change the owner of function add to dbadmin:

1
ALTER FUNCTION add_two_number(INTEGER, INTEGER) OWNER TO dbadmin;

Helpful Links

CREATE FUNCTION, DROP FUNCTION