You can use the ALTER FUNCTION statement to recompile an independent function.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.
Prerequisites
If the function is in the schema of the SYS user, you must connect to the database with the SYSDBA role. Otherwise, the function must be located in your own schema, or you 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 } ;
The syntax of function_compile_clause is 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 your schema. |
| alter_function | function_name | The name of the function to be recompiled. |
| function_compile_clause | -- | Recompiles this function regardless of whether the function is valid. |
Examples
The following example explicitly recompiles the get_salary_by_dept function of the SYS user:
ALTER FUNCTION sys.get_salary_by_dept COMPILE;
If the database does not encounter an error when it recompiles get_salary_by_dept, get_salary_by_dept becomes valid. The database can directly run this function later without the need to recompile it.
If the database encounters an error when it recompiles the get_salary_by_dept function, it returns an error and invalidates get_salary_by_dept. The database also invalidates all objects that depend on get_salary_by_dept. If these objects are referenced later without being explicitly recompiled, the database will implicitly recompile the objects during running.