ERROR 1426(42000)第20行:精度太高14

时间:2014-02-19 21:33:00

标签: mysql database

我已经获得了一个sql文件,并尝试使用MySQL命令行导入它。当我输入以下内容时

C:\Users\MyUser\Desktop\SQL>mysql -u root -p < memory.sql
Enter password: **********

我收到此错误

ERROR 1426 (42000) at line 20: Too big precision 14 specified for column 'lastmod'. Maximum is 6

所以我在文本编辑器中打开了sql文件,更改了14到6,再次尝试导入,我得到了这个:

ERROR 1064 (42000) at line 20: 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 'TYPE=MyISAM' at line 16

以下是创建表

CREATE TABLE AccessCard (
 ID int(11) NOT NULL auto_increment,
 personID int(11) NOT NULL default '0',
 cardFormatID int(11) NOT NULL default '0',
 cardNumber char(6) binary default NULL,
 friendNumber bigint(20) default NULL,
 disabled tinyint(1) NOT NULL default '0',
 issueCode int(11) default NULL,
 lastmod timestamp(14) NOT NULL,
 lastmodPersonID int(11) default NULL,
 PRIMARY KEY  (ID),
 UNIQUE KEY Alter_Key1 (cardFormatID,cardNumber),
 KEY AI_ID (ID),
 KEY IX_cardFormatToAccessCard (cardFormatID),
 KEY IX_PersonToAccessCard (personID)
 ) TYPE=MyISAM;

我用谷歌搜索了这个,我发现的唯一的东西让我来到这里,但它似乎是来自创建新数据库的人。我对MySQL很新,所以要温柔。谢谢!

1 个答案:

答案 0 :(得分:5)

这适用于MySQL 5.5.32。

CREATE TABLE AccessCard (
 ID int(11) NOT NULL auto_increment,
 personID int(11) NOT NULL default '0',
 cardFormatID int(11) NOT NULL default '0',
 cardNumber char(6) binary default NULL,
 friendNumber bigint(20) default NULL,
 disabled tinyint(1) NOT NULL default '0',
 issueCode int(11) default NULL,
 lastmod timestamp NOT NULL,
 lastmodPersonID int(11) default NULL,
 PRIMARY KEY  (ID),
 UNIQUE KEY Alter_Key1 (cardFormatID,cardNumber),
 KEY AI_ID (ID),
 KEY IX_cardFormatToAccessCard (cardFormatID),
 KEY IX_PersonToAccessCard (personID)
 ) ENGINE=MyISAM;

有两处变化。

  • lastmod timestamp NOT NULL,行中删除“(14)”。
  • type=MyISAM更改为ENGINE=MyISAM。 (在您的服务器上可能没有必要。我不确定这实际上是语法问题还是服务器配置的差异。)

此处可能存在版本不匹配或服务器配置不匹配。我的版本不会将时间戳列转储为timestamp(14)。我的版本只将其转储为timestamp