lava-oushudb-dt-sql-parser/test/parser/mysql/syntax/fixtures/createTrigger.sql
琉易 428d851913
feat: #190 improve mysql grammer (#196)
* refactor: generic rename to mysql

* refactor: g4 with mysql syntax

* test: mysql syntax

* refactor: remove useless keywords

* refactor: remove nonReserved keywords

* refactor: lint specificFunction

---------

Co-authored-by: liuyi <liuyi@dtstack.com>
2023-11-27 15:25:40 +08:00

23 lines
1.0 KiB
SQL

-- https://dev.mysql.com/doc/refman/8.0/en/create-trigger.html
/* CREATE
[DEFINER = user]
TRIGGER [IF NOT EXISTS] trigger_name
{ BEFORE | AFTER }
{ INSERT | UPDATE | DELETE }
ON tbl_name FOR EACH ROW
[{ FOLLOWS | PRECEDES } other_trigger_name]
trigger_body
*/
CREATE TRIGGER IF NOT EXISTS my_trigger BEFORE INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger BEFORE INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER UPDATE ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER DELETE ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW FOLLOWS other_trigger_name SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW PRECEDES other_trigger_name SET NEW.column_name = some_value;