/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
# Dumping structure for table test.log
CREATE TABLE IF NOT EXISTS `log` (
`user` varchar(50) DEFAULT NULL,
`table` varchar(50) DEFAULT NULL,
`old` varchar(50) DEFAULT NULL,
`new` varchar(50) DEFAULT NULL,
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# Dumping data for table test.log: ~0 rows (approximately)
/*!40000 ALTER TABLE `log` DISABLE KEYS */;
/*!40000 ALTER TABLE `log` ENABLE KEYS */;
# Dumping structure for table test.tabula
CREATE TABLE IF NOT EXISTS `tabula` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`dati1` int(10) unsigned NOT NULL DEFAULT '0',
`dati2` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
# Dumping data for table test.tabula: ~3 rows (approximately)
/*!40000 ALTER TABLE `tabula` DISABLE KEYS */;
INSERT INTO `tabula` (`id`, `dati1`, `dati2`) VALUES
(1, 234234, 234234),
(2, 234234, 234234),
(3, 234234, 234234);
/*!40000 ALTER TABLE `tabula` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
--------------------------------------------------------------------------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
# Dumping structure for trigger test.tabula_onupdate
SET SESSION SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `tabula_onupdate` AFTER UPDATE ON `tabula` FOR EACH ROW BEGIN
INSERT INTO `log` SET `log`.`user` = USER(), `log`.`table`='tabula', `log`.`old` = OLD.dati1, `log`.`new`= NEW.dati1;
END//
DELIMITER ;
SET SESSION SQL_MODE=@OLD_SQL_MODE;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
--------------------------------------------------------------------------------------------------------------------------
Комментариев нет:
Отправить комментарий