Item Archive


MySQL Triggers Public New

Easy 

7min


Fill in the blanks so that the trigger item_delete inserts name from item table to the item_archive table, after a row from the table item is deleted.

CREATE TABLE item (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  quantity INT NOT NULL
);

CREATE TABLE item_archive (
  archive_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50) NOT NULL
);

DELIMITER $$
CREATE  item_delete  ON item 
FOR EACH ROW
BEGIN
  INSERT INTO item_archive(name) VALUES ();
END;
$$
DELIMITER ;

See the example case for more details.