创建DOUBLE字段失败,错误1064:MySQL

时间:2013-09-23 12:48:29

标签: mysql mysql-workbench

我正在尝试建立一个数据库,以了解有关MySQL中触发器的更多信息。

所以我使用mysql-workbench创建了一个数据库模型。如果我尝试将模型与mysql-server同步,我会收到1064语法错误:

Executing SQL script in server
ERROR: Error 1064: 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 ') NOT NULL ,
  PRIMARY KEY (`employee_id`, `accounts_id`) ,
  INDEX `fk_accountA' at line 4


CREATE  TABLE IF NOT EXISTS `pzedb`.`accountAmounts` (
  `employee_id` INT(11) NOT NULL ,
  `accounts_id` INT(11) NOT NULL ,
  `accountAmount` DOUBLE(11) NOT NULL ,
  PRIMARY KEY (`employee_id`, `accounts_id`) ,
  INDEX `fk_accountAmounts_employee1` (`employee_id` ASC) ,
  INDEX `fk_accountAmounts_accounts1` (`accounts_id` ASC) ,
  CONSTRAINT `fk_accountAmounts_employee1`
    FOREIGN KEY (`employee_id` )
    REFERENCES `pzedb`.`employee` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_accountAmounts_accounts1`
    FOREIGN KEY (`accounts_id` )
    REFERENCES `pzedb`.`accounts` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci

SQL script execution finished: statements: 11 succeeded, 1 failed

我尝试将字段更改为VARCHAR,我应该说它有效。我将其他字段更改为DOUBLE并得到相同的错误。

是否有问题或者我使用工作台太愚蠢了?

我的操作系统:Debian 7.1 MySQL:5.5.31-0 + wheezy1 工作台:5.2.40 rev 8790

1 个答案:

答案 0 :(得分:2)

Double不接受长度。在你的情况下它应该只是

accountAmount DOUBLE NOT NULL

对于整数INT(11),它并不意味着长度为11.它仅在ZEROFILL时使用,它使用0填充数字,在DDL中指定选项。例如

INT(4)    INT(4) ZEROFILL
12           0012
122          0122
12222       12222