这个创建表语法有什么问题
这是我创建的表,这是我收到的错误
DROP TABLE IF EXISTS `teamfocus_dbo`.`sysdiagrams`;
CREATE TABLE `teamfocus_dbo`.`sysdiagrams` (
`name` VARCHAR(128) 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;
错误
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
我什至尝试取出唯一的行但仍然出错......任何想法
Here is my create table and this is the error I am getting
DROP TABLE IF EXISTS `teamfocus_dbo`.`sysdiagrams`;
CREATE TABLE `teamfocus_dbo`.`sysdiagrams` (
`name` VARCHAR(128) 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;
ERROR
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
I even tried to take out the UNIQUE line and still erroring...any ideas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于大多数数据库,
-1
不是VARBINARY
的有效长度:SQL Server:
http://msdn.microsoft.com/en-us/library/ms188362.aspx
MySQL: http://dev.mysql.com/doc/refman /5.0/en/binary-varbinary.html
引用
VARCHAR
,它提供以下限制:http://dev.mysql.com/doc/refman/5.0/en /char.html
-1
isn't a valid length forVARBINARY
for most databases:SQL Server:
http://msdn.microsoft.com/en-us/library/ms188362.aspx
MySQL: http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
Refers to
VARCHAR
which provides the following limits:http://dev.mysql.com/doc/refman/5.0/en/char.html