Search
 
SCRIPT & CODE EXAMPLE
 

SQL

Triggers in MySQL example

delimiter //
CREATE TRIGGER person_ai AFTER INSERT
ON person
FOR EACH ROW
UPDATE average_age SET average = (SELECT AVG(age) FROM person); //
delimiter ;
Comment

trigger in mysql syntax

CREATE TRIGGER trigger_name
{BEFORE | AFTER} {INSERT | UPDATE| DELETE }
ON table_name FOR EACH ROW
trigger_body;
Comment

Triggers in MySQL example

delimiter //
CREATE TRIGGER person_bu BEFORE UPDATE
ON person
FOR EACH ROW
IF NEW.age < 18 THEN
SIGNAL SQLSTATE '50002' SET MESSAGE_TEXT = 'Person must be older than 18.';
END IF; //
delimiter ;
Comment

trigger in mysql

CREATE TRIGGER Product_Details_tr 
BEFORE INSERT ON Product_Details 
FOR EACH ROW 
SET NEW.User_ID = CURRENT_USER();
Comment

Triggers in MySQL example

delimiter //
CREATE TRIGGER person_bi BEFORE INSERT
ON person
FOR EACH ROW
IF NEW.age < 18 THEN
SIGNAL SQLSTATE '50001' SET MESSAGE_TEXT = 'Person must be older than 18.';
END IF; //
delimiter ;
Comment

triggers in mysql

A trigger is a set of codes that executes in response to some events.
Comment

PREVIOUS NEXT
Code Example
Sql :: offset in postgresql example 
Sql :: rename temp table column name in sql server 
Sql :: postgres meta command to show all rows in table 
Sql :: Failed to process SQL command - ORA-28014: cannot drop administrative user or role 
Sql :: mysql varchar length 
Sql :: sql alternative to max statement 
Sql :: how to dump .csv file into mysql 
Sql :: sql update by id 
Sql :: linux upload database to mysql 
Sql :: sql not exists 
Sql :: how to assign custom id in mysql 
Sql :: sql max count 
Sql :: syntax error at or near "AUTO_INCREMENT" 
Sql :: REMOVE DATE FROM DATE TIME SQL SERVER 
Sql :: sql searching via key word 
Sql :: mysql set column equal to another automatic 
Sql :: what does leave do in mysql 
Sql :: postgresql between 
Sql :: oracle sql count occurrences of value in column 
Sql :: postgresql connect 
Sql :: postgres execute multiple sql file from command line 
Sql :: sql join 3 tables 
Sql :: Deleting data from tables 
Sql :: how to get capital letter first in sql 
Sql :: delete join sql server 
Sql :: sql double quotes in string 
Sql :: how do you insert boolean to postgresql 
Sql :: postgresql functions 
Sql :: fuck docker mysql 
Sql :: add column to all tables after first column mysql 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =