Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have another syntax error when migrating a diagram. I'm not certain this diagram is necessary, but it would be nice to have a smooth migration, and this is all that's standing in the way.

The error is: 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 '-1) NULL, PRIMARY KEY ('diagram_id'), UNIQUE INDEX 'UK_principal_name' ('pri' at line 6

And the syntax has a VARBINARY(-1) which I've never seen before. Is that the problem?

DROP TABLE IF EXISTS `Fonebook_dbo`.`sysdiagrams`;
CREATE TABLE `Fonebook_dbo`.`sysdiagrams` (
  `name` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `principal_id` INT(10) NOT NULL,
  `diagram_id` INT(10) NOT NULL AUTO_INCREMENT,
  `version` INT(10) NULL,
  `definition` VARBINARY(-1) NULL,
  PRIMARY KEY (`diagram_id`),
  UNIQUE INDEX `UK_principal_name` (`principal_id`, `name`)
)
ENGINE = INNODB;
share|improve this question

2 Answers 2

up vote 0 down vote accepted

VARBINARY(-1), -1 is a length of binary. Set the correct length, such 100

  `definition` VARBINARY(100) NULL,
share|improve this answer
    
I ended up ignoring the object altogether, thanks. –  gr33d Sep 22 '10 at 16:35

I'm not experienced with the data type but I'm guessing that is the issue:

The permissible maximum length is the same for BINARY and VARBINARY as it is for CHAR and VARCHAR, except that the length for BINARY and VARBINARY is a length in bytes rather than in characters.

So yeah, I don't think negative 1 bytes is a valid length.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.