drop database if exists provisioning; create database provisioning default character set utf8 default collate utf8_general_ci; use provisioning; CREATE TABLE IF NOT EXISTS `type` ( `id` smallint(3) NOT NULL auto_increment , `brand` varchar(30) NOT NULL, `model` varchar(30) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique` (`brand`(4),`model`(4)) ) ENGINE=MyISAM comment='This table show what brands and models there are' AUTO_INCREMENT=1 ; CREATE TABLE `old_type` ( `old_id` INT( 4 ) NOT NULL AUTO_INCREMENT , `old_brand` VARCHAR( 30 ) , `old_model` VARCHAR( 30 ) , `old_reason` varchar(3), `old_changedate` timestamp, primary key (`old_id`) ) ENGINE = MYISAM ; delimiter | create trigger type_after_insert after insert on `type` for each row begin insert into `old_type` set `old_brand` = `brand`, `old_model` = `model`, `old_reason` = 'ins', `old_changedate` = now(); end; | commit;