mysql> CREATE TABLE IF NOT EXISTS `onces201404` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`station_id` int(11) DEFAULT NULL,
`artist_id` int(11) DEFAULT NULL,
`song_id` int(11) DEFAULT NULL,
`time` datetime DEFAULT NULL,
`pad_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `station_id` (`station_id`),
KEY `artist_id` (`artist_id`),
KEY `song_id` (`song_id`),
CONSTRAINT `once201404_ibfk_1` FOREIGN KEY (`station_id`) REFERENCES `Station` (`ID`),
CONSTRAINT `once201404_ibfk_2` FOREIGN KEY (`artist_id`) REFERENCES `Artists` (`ID`),
CONSTRAINT `once201404_ibfk_3` FOREIGN KEY (`song_id`) REFERENCES `Songs` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=243204 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ERROR 1005 (HY000): Can't create table 'DB_Music.onces201404' (errno: 150)
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS `onces201404` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`station_id` int(11) DEFAULT NULL,
`artist_id` int(11) DEFAULT NULL,
`song_id` int(11) DEFAULT NULL,
`time` datetime DEFAULT NULL,
`pad_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `station_id` (`station_id`),
KEY `artist_id` (`artist_id`),
KEY `song_id` (`song_id`),
CONSTRAINT `once201404_ibfk_1` FOREIGN KEY (`station_id`) REFERENCES `Station` (`ID`),
CONSTRAINT `once201404_ibfk_2` FOREIGN KEY (`artist_id`) REFERENCES `Artists` (`ID`),
CONSTRAINT `once201404_ibfk_3` FOREIGN KEY (`song_id`) REFERENCES `Songs` (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=243204 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.19 sec)
set @a=(select a from t where id=1);
SELECT TRIGGER_NAME
FROM information_schema.triggers
WHERE TRIGGER_SCHEMA = 'db_name' AND TRIGGER_NAME = 'trigger_name'
-http://bbs.phpchina.com/thread-51885-1-1.html
-http://stackoverflow.com/questions/11221524/workaround-for-mysql-create-trigger-if-not-exist