DROP TRIGGER

DROP TRIGGER — remove a trigger

Synopsis

The following syntax drop the trigger defined with function name:

DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]

The following syntax is available in Oracle mode, and drop the trigger defined with code block:

DROP TRIGGER [schema .] name

Description

DROP TRIGGER removes an existing trigger definition. To execute this command, the current user must be the owner of the table for which the trigger is defined.

Parameters

IF EXISTS

Do not throw an error if the trigger does not exist. A notice is issued in this case.

schema

Name of the schema containing the trigger. Default: current schema.

name

The name of the trigger to remove.

table_name

The name (optionally schema-qualified) of the table for which the trigger is defined.

CASCADE

Automatically drop objects that depend on the trigger, and in turn all objects that depend on those objects (see Section 5.14).

RESTRICT

Refuse to drop the trigger if any objects depend on it. This is the default.

Examples

Create and destroy the trigger if_dist_exists on the table films:

CREATE TRIGGER if_dist_exists after INSERT ON films FOR EACH ROW
EXECUTE FUNCTION if_dist_exists_func();
DROP TRIGGER if_dist_exists ON films;

Create and destroy the trigger if_dist_exists_oracle on the table films:

CREATE TRIGGER if_dist_exists_oracle after INSERT ON films FOR EACH ROW
begin
dbms_output.put_line('hello world!');
end;
/
DROP TRIGGER if_dist_exists_oracle;

Compatibility

The DROP TRIGGER statement in LightDB is incompatible with the SQL standard. In the SQL standard, trigger names are not local to tables, so the command is simply DROP TRIGGER name.

See Also

CREATE TRIGGER
English|中文