CREATE TABLE `applications` (
`id` int(2) NOT NULL,
`applicationID` varchar(36) character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationType` enum('M','W') character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationName` varchar(30) character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationPath` varchar(100) character set utf8 collate utf8_unicode_ci NOT NULL,
`isDeleted` tinyint(1) NOT NULL default '0',
`lastModified` timestamp NOT NULL default CURRENT_TIMESTAMP
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
-
- 转储表applications
的数据
-
INSERT INTO `applications` (`id`, `applicationID`, `applicationType`, `applicationName`, `applicationPath`, `isDeleted`, `lastModified`) VALUES (1, 'a49af37e-7f4c-1032-a010- c067c39cc60b', 'W', 'workshopWorkerWeb', 'http://www.workshopworker.com/workshopWorkerLogin/workshopWorkerLogin.html', 0, '2014-08-27 15:11:46'),
(2, 'a49af5c2-7f4c-1032-a010-c067c39cc60b', 'W', 'agriMapper', '', 0, '2014-08-27 15:11:46'),
(3, 'a49af702-7f4c-1032-a010-c067c39cc60b', 'M', 'promacRegistration', 'https://play.google.com/store/apps/details?id=com.ncbaclusapromac.ncbaclusapromac', 0, '2014-08-27 15:11:46'),
(4, 'a49af838-7f4c-1032-a010-c067c39cc60b', 'M', 'eBAF', 'https://play.google.com/store/apps/details?id=com.ncbaclusapromac.eBAF', 0, '2014-08-27 15:11:46'),
(5, 'a49af996-7f4c-1032-a010-c067c39cc60b', 'M', 'extensionWorker', 'https://play.google.com/store/apps/details?id=pt.com.extensionWorker', 0, '2014-08-27 15:11:46'),
(6, 'a49afad6-7f4c-1032-a010-c067c39cc60b', 'W', 'promacAdministration', ' 'http://ncbaclusapromac.com/clientLogin.html', 0, '2014-08-27 15:11:46');
DELIMITER $$
CREATE TRIGGER `applicationsUUID` BEFORE INSERT ON `applications`
FOR EACH ROW BEGIN
IF NEW.applicationID = '' THEN
SET NEW.applicationID = UUID();
END IF;
END
$$
DELIMITER ;
给出: - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'DELIMITER $$
附近使用正确的语法我知道DELIMITER语法有问题,但我看不到哪里。
答案 0 :(得分:0)
尝试:
CREATE TABLE `applications` (
`id` int(2) NOT NULL,
-- `applicationID` varchar(36) character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationID` varchar(39) character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationType` enum('M','W') character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationName` varchar(30) character set utf8 collate utf8_unicode_ci NOT NULL,
`applicationPath` varchar(100) character set utf8 collate utf8_unicode_ci NOT NULL,
`isDeleted` tinyint(1) NOT NULL default '0',
`lastModified` timestamp NOT NULL default CURRENT_TIMESTAMP
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
INSERT INTO `applications` (`id`, `applicationID`, `applicationType`, `applicationName`, `applicationPath`, `isDeleted`, `lastModified`)
VALUES
(1, 'a49af37e-7f4c-1032-a010- c067c39cc60b', 'W', 'workshopWorkerWeb', 'http://www.workshopworker.com/workshopWorkerLogin/workshopWorkerLogin.html', 0, '2014-08-27 15:11:46'),
(2, 'a49af5c2-7f4c-1032-a010-c067c39cc60b', 'W', 'agriMapper', '', 0, '2014-08-27 15:11:46'),
(3, 'a49af702-7f4c-1032-a010-c067c39cc60b', 'M', 'promacRegistration', 'https://play.google.com/store/apps/details?id=com.ncbaclusapromac.ncbaclusapromac', 0, '2014-08-27 15:11:46'),
(4, 'a49af838-7f4c-1032-a010-c067c39cc60b', 'M', 'eBAF', 'https://play.google.com/store/apps/details?id=com.ncbaclusapromac.eBAF', 0, '2014-08-27 15:11:46'),
(5, 'a49af996-7f4c-1032-a010-c067c39cc60b', 'M', 'extensionWorker', 'https://play.google.com/store/apps/details?id=pt.com.extensionWorker', 0, '2014-08-27 15:11:46'),
-- (6, 'a49afad6-7f4c-1032-a010-c067c39cc60b', 'W', 'promacAdministration', ' 'http://ncbaclusapromac.com/clientLogin.html', 0, '2014-08-27 15:11:46');
(6, 'a49afad6-7f4c-1032-a010-c067c39cc60b', 'W', 'promacAdministration', 'http://ncbaclusapromac.com/clientLogin.html', 0, '2014-08-27 15:11:46');
DELIMITER $$
CREATE TRIGGER `applicationsUUID` BEFORE INSERT ON `applications`
FOR EACH ROW
BEGIN
IF NEW.applicationID = '' THEN
SET NEW.applicationID = UUID();
END IF;
END$$
DELIMITER ;