MySQl触发器实例

use dorm;
delimiter $$
create trigger student_score_red
	after  insert on grade
    for each row
    begin
		declare s float;
        set s = new.score;
        if(s < 90) then
			update student 
            set student.score = student.score - 1
            where student.Sbno = new.gbno and student.Sdno = new.gbno;
		end if;
	end
    $$

 

你可能感兴趣的:(MySQL)