1

i'm trying to build up a database to learn more about Triggers in MySQL.

So i created an database model with the mysql-workbench. If i try to synchronize the model with the mysql-server, i get a 1064 syntax error:

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

I tried to change the field to VARCHAR and what should i say it worked. I changed other fields to DOUBLE and get the same error.

Is there something wrong or i'm just too stupid to use the workbench?

My OS: Debian 7.1 MySQL: 5.5.31-0+wheezy1 Workbench: 5.2.40 rev 8790

commandcraxx
  • 243
  • 1
  • 7
  • 23

1 Answers1

3

Double does not accept length. SO in your case it should only be

accountAmount DOUBLE NOT NULL

For integer, INT(11), it does not mean that the length is 11. It is simply used when ZEROFILL, which pads the number with 0, option is specified in DDL. eg

INT(4)    INT(4) ZEROFILL
12           0012
122          0122
12222       12222
Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • Seems to be there is a bug in the workbench. I had chosen the DOUBLE without length or something. Thank You for your answer, it works now. BTW. i added this table manually to get it working. – commandcraxx Sep 23 '13 at 13:14