The ALTER FUNCTION statement is used to recompile standalone functions.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL-compatible mode.
Prerequisites
If the function is in the SYS schema, you must connect as SYSDBA. Otherwise, the function must be in the current user's schema, or the user must have the ALTER ANY PROCEDURE system privilege.
Syntax
The syntax of ALTER FUNCTION is as follows:
ALTER FUNCTION [ schema. ] function_name
{ function_compile_clause } ;
where function_compile_clause is specified as follows:
COMPILE [ DEBUG ] [ compiler_parameters_clause ... ] [ REUSE SETTINGS ]
Semantics
| Syntax | Keyword or syntax node | Description |
|---|---|---|
| alter_function | schema | The name of the schema where the function is located. The default value is the current user's schema. |
| alter_function | function_name | The name of the function to be recompiled. |
| function_compile_clause | -- | Recompiles the function regardless of its validity. |
Examples
The following example explicitly recompiles the get_salary_by_dept function owned by the sys user.
ALTER FUNCTION sys.get_salary_by_dept COMPILE;
If no compilation errors occur during the recompilation of get_salary_by_dept, the function becomes valid. The database can then execute it without recompiling it at runtime.
If the recompilation of get_salary_by_dept results in compilation errors, the database returns an error, and get_salary_by_dept becomes invalid. The database also invalidates all objects that depend on get_salary_by_dept. If these objects are subsequently referenced without being explicitly recompiled, the database will implicitly recompile them at runtime.