You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@iotdb.apache.org by 苏志 <27...@qq.com.INVALID> on 2022/05/01 15:22:57 UTC

Documentation on the use of triggers

The following shows the SQL syntax of registering a trigger.

CREATE TRIGGER <TRIGGER-NAME&gt;
(BEFORE | AFTER) INSERT ON <FULL-PATH&gt; AS <CLASSNAME&gt; WITH (   <KEY-1&gt;=<VALUE-1&gt;,    <KEY-2&gt;=<VALUE-2&gt;,    ... )TRIGGER-NAME is a globally unique ID of the trigger, which is case sensitive. At present, the trigger can listen to all data insertion operations on the time series. The hook can be called BEFORE or AFTER the data is inserted. FULL-PATH can be a time-series (measurement) path such as root.sg1.d1.s1, a device path such as root.sg1.d1, a storage group path such as root.sg1, or even a non-measurement path with business semantic such as root.sg1.x. CLASSNAME is the full class name of the trigger. Note 
CLASSNAME, KEY and VALUE in the attributes need to be quoted in single or double quotes.

Only one trigger can be registered per full-path.

When multiple prefix paths of a path are registered with triggers, for example, trigger trigger-sg1d1s1 is registed on root.sg1.d1, trigger trigger-sg1d1 is registed on root.sg1.d1, and trigger trigger-sg1 is registed on root.sg1. When inserting data to root.sg1.d1.s1, triggers will be triggered in the following order: trigger-sg1d1s1 -&gt; trigger-sg1d1 -&gt; trigger-sg1.

Best,
------------------------------------
gongning

Re: Documentation on the use of triggers

Posted by Steve Yurong Su <ro...@apache.org>.
Hi Ning,

Thanks for your contribution! The PR looks good to me, I have merged it.

Steve Su

苏志 <27...@qq.com.invalid> 于2022年5月1日周日 23:23写道:
>
> The following shows the SQL syntax of registering a trigger.
>
> CREATE TRIGGER <TRIGGER-NAME&gt;
> (BEFORE | AFTER) INSERT ON <FULL-PATH&gt; AS <CLASSNAME&gt; WITH (   <KEY-1&gt;=<VALUE-1&gt;,    <KEY-2&gt;=<VALUE-2&gt;,    ... )TRIGGER-NAME is a globally unique ID of the trigger, which is case sensitive. At present, the trigger can listen to all data insertion operations on the time series. The hook can be called BEFORE or AFTER the data is inserted. FULL-PATH can be a time-series (measurement) path such as root.sg1.d1.s1, a device path such as root.sg1.d1, a storage group path such as root.sg1, or even a non-measurement path with business semantic such as root.sg1.x. CLASSNAME is the full class name of the trigger. Note
> CLASSNAME, KEY and VALUE in the attributes need to be quoted in single or double quotes.
>
> Only one trigger can be registered per full-path.
>
> When multiple prefix paths of a path are registered with triggers, for example, trigger trigger-sg1d1s1 is registed on root.sg1.d1, trigger trigger-sg1d1 is registed on root.sg1.d1, and trigger trigger-sg1 is registed on root.sg1. When inserting data to root.sg1.d1.s1, triggers will be triggered in the following order: trigger-sg1d1s1 -&gt; trigger-sg1d1 -&gt; trigger-sg1.
>
> Best,
> ------------------------------------
> gongning