1CREATE TRIGGER Product_Details_tr
2BEFORE INSERT ON Product_Details
3FOR EACH ROW
4SET NEW.User_ID = CURRENT_USER();
1-- Oracle DB Syntax
2CREATE OR REPLACE TRIGGER {trigger_name}
3BEFORE | AFTER
4INSERT | UPDATE | DELETE
5ON {table_name}
6(FOR EACH ROW)
7{operation to be executed}
8
9-- for example
10CREATE TRIGGER log_updates
11AFTER INSERT OR UPDATE ON Person
12FOR EACH ROW
13INSERT INTO LogPerson(ts, IdPerson, surname)
14VALUES(CURRENT_TIMESTAMP, NEW.id, NEW.surname);
1-- SQL Server Syntax
2-- Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger)
3
4CREATE [ OR ALTER ] TRIGGER [ schema_name . ]trigger_name
5ON { table | view }
6[ WITH <dml_trigger_option> [ ,...n ] ]
7{ FOR | AFTER | INSTEAD OF }
8{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
9[ WITH APPEND ]
10[ NOT FOR REPLICATION ]
11AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }
12
13<dml_trigger_option> ::=
14 [ ENCRYPTION ]
15 [ EXECUTE AS Clause ]
16
17<method_specifier> ::=
18 assembly_name.class_name.method_name
19
20
1-- Azure SQL Database Syntax
2-- Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger)
3
4CREATE [ OR ALTER ] TRIGGER [ schema_name . ]trigger_name
5ON { table | view }
6 [ WITH <dml_trigger_option> [ ,...n ] ]
7{ FOR | AFTER | INSTEAD OF }
8{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
9 AS { sql_statement [ ; ] [ ,...n ] [ ; ] > }
10
11<dml_trigger_option> ::=
12 [ EXECUTE AS Clause ]
13
14