2016-06-24 6 views
-2
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 
SET time_zone = "+00:00"; 
USE `textplus`; 
CREATE TABLE IF NOT EXISTS `users` (
`id` int(9) unsigned NOT NULL AUTO_INCREMENT, 
`username` varchar(25) NOT NULL DEFAULT '', 
`password` varchar(20) NOT NULL DEFAULT '', 
`email` varchar(40) NOT NULL DEFAULT '', 
`status` tinyint(3) unsigned NOT NULL DEFAULT '0', 
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
`authenticationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
`userKey` varchar(20) NOT NULL DEFAULT '', 
`IP` varchar(45) NOT NULL DEFAULT '', 
`port` int(10) unsigned NOT NULL DEFAULT '0', 
PRIMARY KEY (`id`), 
UNIQUE KEY `Index_2` (`username`), 
KEY `Index_3` (`authenticationTime`), 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; 

CREATE TABLE IF NOT EXISTS `friends`(
`Id` int(9) unsigned NOT NULL AUTO_INCREMENT, 
`whoProvideId` int(9) unsigned NOT NULL DEFAULT '0', 
`whoRequestId` int(9) unsigned NOT NULL DEFAULT '0', 
`status` binary(1) NOT NULL DEFAULT '0', 
PRIMARY KEY(`Id`), 
UNIQUE KEY `Index_3` (`whoProvideId`,`whoRequestId`), 
KEY `Index_2` (`whoProvideId`,`whoRequestId`,`status`), 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='whoProvideId is the Id of the users who wish to be friend with' AUTO_INCREMENT=7; 

CREATE TABLE IF NOT EXISTS `messages`(
`id` int(255) NOT NULL AUTO_INCREMENT, 
`fromWhoId` int(255) NOT NULL , 
`toWhoId` int(9) NOT NULL, 
`sendDate` datetime NOT NULL, 
`read` tinyint(1) NOT NULL DEFAULT '0', 
`readDate` datetime DEFAULT NULL, 
`messageTextLong` longText CHARACTER SET utf8 NOT NULL, 
PRIMARY KEY(`id`), 
KEY `id`(`id`), 
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22; 
+0

이 오류입니다 : # 1064 - 당신은 오류가 귀하의 SQL 구문; 당신의 MySQL 서버 버전에 해당하는 매뉴얼을 확인하여 올바른 구문을 찾으십시오. 15 번 라인에서 'ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 7'을 사용하십시오. – shayne

+0

질문에 추가하십시오. – cybermonkey

+0

예를 들어, 다음과 같이 create 절의 마지막 줄 다음에','를 제거하십시오 :'KEY'Index_3' ('authenticationTime'),' – Jens

답변

1

시도를 작동하지 않으며 작업을 완료,

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 
SET time_zone = "+00:00"; 

CREATE TABLE IF NOT EXISTS `users` (
`id` int(9) unsigned NOT NULL AUTO_INCREMENT, 
`username` varchar(25) NOT NULL DEFAULT '', 
`password` varchar(20) NOT NULL DEFAULT '', 
`email` varchar(40) NOT NULL DEFAULT '', 
`status` tinyint(3) unsigned NOT NULL DEFAULT '0', 
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
`authenticationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
`userKey` varchar(20) NOT NULL DEFAULT '', 
`IP` varchar(45) NOT NULL DEFAULT '', 
`port` int(10) unsigned NOT NULL DEFAULT '0', 
PRIMARY KEY (`id`), 
UNIQUE KEY `Index_2` (`username`), 
KEY `Index_3` (`authenticationTime`) --Remove comma from here 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; 

CREATE TABLE IF NOT EXISTS `friends`(
`Id` int(9) unsigned NOT NULL AUTO_INCREMENT, 
`whoProvideId` int(9) unsigned NOT NULL DEFAULT '0', 
`whoRequestId` int(9) unsigned NOT NULL DEFAULT '0', 
`status` binary(1) NOT NULL DEFAULT '0', 
PRIMARY KEY(`Id`), 
UNIQUE KEY `Index_3` (`whoProvideId`,`whoRequestId`), 
KEY `Index_2` (`whoProvideId`,`whoRequestId`,`status`) --Remove comma from here 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='whoProvideId is the Id of the users who wish to be friend with' AUTO_INCREMENT=7; 

CREATE TABLE IF NOT EXISTS `messages`(
`id` int(255) NOT NULL AUTO_INCREMENT, 
`fromWhoId` int(255) NOT NULL , 
`toWhoId` int(9) NOT NULL, 
`sendDate` datetime NOT NULL, 
`read` tinyint(1) NOT NULL DEFAULT '0', 
`readDate` datetime DEFAULT NULL, 
`messageTextLong` longText CHARACTER SET utf8 NOT NULL, 
PRIMARY KEY(`id`), 
KEY `id`(`id`) --Remove comma from here 
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22; 

DEMO

+1

고마워요 – shayne

관련 문제