CQL for Cassandra 2.x

CREATE TRIGGER

Registers a trigger on a table.

Synopsis

CREATE TRIGGER trigger_name ON table_name
USING 'java_class'

Synopsis Legend

  • Uppercase means literal
  • Lowercase means not literal
  • Italics mean optional
  • The pipe (|) symbol means OR or AND/OR
  • Ellipsis (...) means repeatable
  • Orange ( and ) means not literal, indicates scope

A semicolon that terminates CQL statements is not included in the synopsis.

Description

The implementation of triggers includes the capability to register a trigger on a table using the familiar CREATE TRIGGER syntax. This implementation is experimental.
CREATE TRIGGER myTrigger
  ON myTable
  USING 'org.apache.cassandra.triggers.InvertedIndex'

In Cassandra 2.1, you can need to enclose trigger names that use uppercase characters in single quotation marks. The actual logic that makes up the trigger can be written in any Java (JVM) language and exists outside the database. The Java class in this example that implements the trigger is named org.apache.cassandra.triggers and defined in an Apache repository. 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.

Show/hide