简体   繁体   English

#1064 mysql语法错误

[英]#1064 mysql syntax error

I got this error report while importing my sql file. 导入我的sql文件时收到此错误报告。

this is the error report : 这是错误报告:

#1064 - You have an error in your SQL syntax; #1064-您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near '2) NOT NULL default '0.00', employerhdmf decimal(12,2) NOT NULL default '0.00'' at line 8 检查与您的MySQL服务器版本相对应的手册以在'2)NOT NULL default'0.00'附近使用正确的语法,在第8行,ployhdmf decimal(12,2)NOT NULL default'0.00'

here's the code : 这是代码:

CREATE DATABASE kafik9; USE kafik9;

--
-- Table structure for table 'prlemphdmffile'
-- CREATE TABLE prlemphdmffile (   counterindex int(11) NOT NULL auto_increment,   payrollid varchar(10) NOT NULL default '',  
employeeid varchar(10) NOT NULL default '',   grosspay varchar(12,2)
NOT NULL default '0.00',   employerhdmf decimal(12,2) NOT NULL default
'0.00',     employeehdmf decimal(12,2) NOT NULL default '0.00',    
total varchar(12,2) NOT NULL default '0.00',   fsmonth tinyint(4) NOT
NULL default '0',   fsyear double NOT NULL default '0',    PRIMARY KEY
(counterindex) ) TYPE=InnoDB;

there's anybody can help what is going wrong here? 有谁可以帮助解决这里的问题? thanks in advance 提前致谢

First problem is varchar(12,2) . 第一个问题是varchar(12,2) From your comment sounds like that is meant to be decimal . 从您的评论听起来像是decimal You need to change both occurrences to decimal(12,2) . 您需要将两次出现都更改为decimal(12,2)

Next, TYPE=InnoDB needs to be ENGINE=InnoDB 接下来, TYPE=InnoDB需要为ENGINE=InnoDB

This query will work: 此查询将起作用:

  CREATE TABLE prlemphdmffile (   
     counterindex int(11) NOT NULL auto_increment,   
     payrollid varchar(10) NOT NULL default '',  
     employeeid varchar(10) NOT NULL default '',   
     grosspay decimal(12,2) NOT NULL default '0.00',   
     employerhdmf decimal(12,2) NOT NULL default '0.00',     
     employeehdmf decimal(12,2) NOT NULL default '0.00',    
     total decimal(12,2) NOT NULL default '0.00',   
     fsmonth tinyint(4) NOT NULL default '0',   
     fsyear double NOT NULL default '0',    
     PRIMARY KEY(counterindex) ) ENGINE=InnoDB;

From the mysql documentation : 从mysql 文档

CREATE TABLE customers (a INT, b CHAR (20), INDEX (a)) ENGINE=InnoDB;

The older term TYPE is supported as a synonym for ENGINE for backward compatibility, but ENGINE is the preferred term and TYPE is deprecated.

It sounds like TYPE should still work even though it is deprecated, but it did not work on my machine. 听起来,即使TYPE已弃用,但TYPE仍然应该可以使用,但是在我的机器上却无法使用。 Changing to ENGINE did the trick. 改用ENGINE

Update 更新

As pointed out in a comment by @eggyal, the above reference is from the mysql 5.0 docs. 正如@eggyal在评论中指出的那样,以上参考来自mysql 5.0文档。 See the comment below for more information. 有关更多信息,请参见下面的评论。

change these part 改变这些部分

grosspay varchar(12,2) NOT NULL -> grosspay decimal(12,2) NOT NULL

total varchar(12,2) NOT NULL -> total decimal(12,2) NOT NULL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM