从mysql 4.0

时间:2015-05-06 04:22:41

标签: mysql sql

我正在尝试将使用mysql 4.0创建的.sql文件导入到最新版本的mysql中,并且收到有关以下代码的语法错误:

CREATE TABLE edgemap (
  senderid int(10) unsigned default NULL,
  recipientid int(10) unsigned default NULL,
  messageid int(10) unsigned default NULL,
  messagedt timestamp(14) NOT NULL,
  reciptype enum('bcc','cc','to') default NULL,
  subject varchar(255) default NULL,
  KEY senderid (senderid,recipientid),
  KEY messageid (messageid),
  KEY messagedt (messagedt),
  KEY senderid_2 (senderid),
  KEY recipientid (recipientid)
) ENGINE=MyISAM; 

我收到的错误消息是:

ERROR 1064 (42000) at line 255752: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14) NOT NULL,
  reciptype enum('bcc','cc','to') default NULL,
  subject varchar' at line 5

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:2)

时间戳的最大精度为6(微秒):

http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

所以将其改为

 messagedt timestamp NOT NULL,

 messagedt timestamp(6) NOT NULL,

http://sqlfiddle.com/#!9/221c13

答案 1 :(得分:-1)

枚举可能不会默认允许在mysql 5中使用NULL值,请尝试将该行更改为:

reciptype enum('bcc','cc','to') NULL,