Once created, the trigger can be removed using the DROP TRIGGER:
Code:
DROP TRIGGER [database.] Name
Obviously the name of the database, if omitted, is considered equal to the database. It is important to note that, prior to MySQL 5.0.10, this statement requires the name of the trigger was not qualified by the name of the database, but with that of the table on which he was associated. It follows that, if the upgrade from a previous version 5.0.10, you must drop triggers before upgrading and re-create them afterwards, otherwise the DROP TRIGGER will not work after the upgrade. Let's see a practical example of trigger:
Code:
delimiter //
CREATE TRIGGER BEFORE UPDATE ON account upd_check
FOR EACH ROW
BEGIN
NEW.amount IF <0 THEN
December NEW.amount = 0;
ELSEIF NEW.amount> 100 THEN
December NEW.amount = 100;
END IF;
END //
delimiter;
This code is activated before any update on the table an account on each of the lines is controlled by changing the value that is being assigned to the field amount to make sure it is between 0 and 100, otherwise is set within these limits. As you can see, then, through the trigger we can change the value that is being updated on the table.
Bookmarks