ALTER FUNCTION (UDF or UDT)
Alters a user defined function (UDF) or user-defined transform (UDT).
Syntax
ALTER FUNCTION... [[db-name.]schema.]function-name([arg-type1,] ...) ... | SET SCHEMA new_schema ... | RENAME TO new_name ... | SET FENCED bool_val ... | 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 If you do not specify a schema, the table is created in the default schema. |
function-name |
The name of the UDF to alter. You must specify the argument type list, which may be empty. |
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. |
SET FENCED bool_val |
A boolean value that specifies if Fenced Mode is enabled for this function. Valid values are: true - enables Fenced Mode false - disables Fenced Mode Fenced Mode is not available for User Defined Aggregates or User Defined Load. |
Privileges
- Only a superuser or owner can alter a function.
- To rename a function (ALTER FUNCTION RENAME TO) the user must have USAGE and CREATE privilege on schema that contains the function.
- To specify a new schema (ALTER FUNCTION SET SCHEMA), the user must have USAGE privilege on the schema that currently contains the function (old schema) and CREATE privilege on the schema to which the function will be moved (new schema).
Examples
This example renames a function called UDF_one to UDF_two:
=> ALTER FUNCTION UDF_one (int,int) RENAME TO UDF_two;
This example moves the UDF_two function to a new schema called macros
:
=> ALTER FUNCTION UDF_two (int) SET SCHEMA
macros;
This example disables Fenced Mode for the UDF_two
function:
=> ALTER FUNCTION UDF_two (int, int) SET FENCED
false;