Triggers¶
Triggers are identified by a name defined by:
trigger_name ::= identifier
CREATE TRIGGER¶
Creating a new trigger uses the CREATE TRIGGER statement:
create_trigger_statement ::= CREATE TRIGGER [ IF NOT EXISTS ]trigger_nameONtable_nameUSINGstring
For instance:
CREATE TRIGGER myTrigger ON myTable USING 'org.apache.cassandra.triggers.InvertedIndex';
The actual logic that makes up the trigger can be written in any Java (JVM) language and exists outside the database.
You place the trigger code in a lib/triggers subdirectory of the Cassandra installation directory, it loads during
cluster startup, and exists on every node that participates in a cluster. The trigger defined on a table fires before a
requested DML statement occurs, which ensures the atomicity of the transaction.
DROP TRIGGER¶
Dropping a trigger uses the DROP TRIGGER statement:
drop_trigger_statement ::= DROP TRIGGER [ IF EXISTS ]trigger_nameONtable_name
For instance:
DROP TRIGGER myTrigger ON myTable;