ALTER FUNCTION (SQL)

Alters a user-defined SQL function.

Syntax

ALTER FUNCTION... [[db-name.]schema.]function-name([arg-type1], ...)
... | SET SCHEMA new_schema
... | RENAME TO new_name
... | OWNER TO new_owner

Parameters

[db-name.]schema

Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example:

myschema.thisDbObject
function-name

The name of the SQL function to alter. Each function requires an accompanying argument, so you must specify the argument type for each function.

RENAME TO new_name

Specifies the new name of the function

SET SCHEMA new_schema

Specifies the new schema name where the function resides.

OWNER TO new_owner
Specifies the new owner of the function.

Privileges

Examples

This example renames a function called SQL_one to SQL_two:

=> ALTER FUNCTION SQL_one (int,int) RENAME TO SQL_two;

This example moves the SQL_two function to a new schema called macros:

=> ALTER FUNCTION SQL_two (int) SET SCHEMA macros;

This example assigns a new owner to SQL_two:

=> ALTER FUNCTION SQL_two (int, int) OWNER TO user1;