SQL Trigger
SQL Trigger
DELIMITER ;
CREATE DEFINER=`root`@`localhost`
TRIGGER `hobby_AFTER_INSERT` AFTER INSERT ON `hobby`
FOR EACH ROW BEGIN
INSERT INTO `practice`.`emp` (`Emp_id`, `name`, `salary`, `mail`) VALUES ('03',
'Tejaswini', '57000', '[email protected]');
END
DELIMITER //
DELIMITER ;
-----------------------------------------------------------------------------------
-------------------
This trigger will delete all rows from the film_actor table whenever a row is
deleted from the film table.
This ensures that the two tables remain in sync and that there are no orphaned rows
in the film_actor table.
-----------------------------------------------------------------------------------
---------------------------
This trigger will update the create_date column in the customer table to the
current timestamp whenever the active column is set to 0.
This can be useful for tracking when customers were deactivated.
-----------------------------------------------------------------------------------
------------------------