Updating trigger mysql 1900 web sex chat
It’s not necessary to define a DELETE trigger since a post is marked as deleted by setting it’s deleted field to true.
CREATE TABLE `audit` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `blog_id` mediumint(8) unsigned NOT NULL, `changetype` enum('NEW','EDIT','DELETE') NOT NULL, `changetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `ix_blog_id` (`blog_id`), KEY `ix_changetype` (`changetype`), KEY `ix_changetime` (`changetime`), CONSTRAINT `FK_audit_blog_id` FOREIGN KEY (`blog_id`) REFERENCES `blog` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=Inno DB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; We require two triggers — AFTER INSERT and AFTER UPDATE on the blog table.
A trigger is defined to activate when a statement inserts, updates, or deletes rows in the associated table. For example, rows can be inserted by statements, and an insert trigger activates for each inserted row.
A trigger can be set to activate either before or after the trigger event.
A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table.
Some uses for triggers are to perform checks of values to be inserted into a table or to perform calculations on values involved in an update.
Triggers have been supported in My SQL since version 5.0.2.