This topic describes the DDL operations on PL stored units, including CREATE, ALTER, and DROP.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
CREATE [OR REPLACE]
You can use the CREATE [OR REPLACE] statement to create a PL unit.
Available CREATE statements include CREATE FUNCTION, CREATE PACKAGE, CREATE PACKAGE BODY, CREATE PROCEDURE, CREATE TRIGGER, CREATE TYPE, and CREATE TYPE BODY.
Each CREATE statement contains an optional OR REPLACE clause. If OR REPLACE is specified, you can re-create a PL unit based on an existing PL unit. To be specific, you can modify the declaration or definition of the PL unit instead of deleting it, and reobtain the object privileges previously granted to this PL unit. After you redefine a PL unit, the database will recompile it.
Notice
The preceding CREATE statements are not allowed in PL blocks.
ALTER
You can use the ALTER statement to recompile a PL unit without the need to re-create it or modify its declaration or definition.
Available ALTER statements include ALTER FUNCTION, ALTER PACKAGE, ALTER PROCEDURE, ALTER TRIGGER, and ALTER TYPE.
You can use the ALTER statement for the following purposes:
Explicitly recompile an invalid stored unit, to avoid recompilation during implicit running and avoid compilation errors and performance overheads during running.
Recompile a stored unit by using different compilation parameters.
Enable or disable a trigger.
DROP
You can use the DROP statement to drop a PL unit.
Available DROP statements include DROP FUNCTION, DROP PACKAGE, DROP PROCEDURE, DROP TRIGGER, DROP TYPE, and DROP TYPE BODY.