Comments on: Restoring from a mysqldump into tables with triggers http://www.xaprb.com/blog/2009/01/08/restoring-from-a-mysqldump-into-tables-with-triggers/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Ms. Anthrope http://www.xaprb.com/blog/2009/01/08/restoring-from-a-mysqldump-into-tables-with-triggers/#comment-15632 Ms. Anthrope Thu, 08 Jan 2009 17:14:56 +0000 http://www.xaprb.com/blog/?p=764#comment-15632 mysqldump in 5.0.67 appears to put triggers after the inserts already:
# mysqldump5 –version
mysqldump Ver 10.11 Distrib 5.0.67, for apple-darwin9.5.0 (i686)


– Table structure for table `customer`

DROP TABLE IF EXISTS `customer`;

CREATE TABLE `customer` (

) ENGINE=InnoDB AUTO_INCREMENT=600 DEFAULT CHARSET=utf8;


– Dumping data for table `customer`

LOCK TABLES `customer` WRITE;
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
INSERT INTO `customer` VALUES (…);
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
UNLOCK TABLES;

DELIMITER ;;
/*!50003 SET SESSION SQL_MODE=”STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER” */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `customer_create_date` BEFORE INSERT ON `customer` FOR EACH ROW SET NEW.create_date = NOW() */;;

DELIMITER ;

Although it would be nice in some cases to disable/enable triggers (especially selectively).

]]>
By: Andrew http://www.xaprb.com/blog/2009/01/08/restoring-from-a-mysqldump-into-tables-with-triggers/#comment-15631 Andrew Thu, 08 Jan 2009 14:36:14 +0000 http://www.xaprb.com/blog/?p=764#comment-15631 I like the Postgres approach to this problem:
ALTER TABLE foo DISABLE TRIGGER ALL;

ALTER TABLE foo ENABLE TRIGGER ALL;

]]>