'unsigned int ..' 附近的未知 CREATE TABLE 语法错误
Unknown CREATE TABLE syntax error near 'unsigned int ..'
我已经盯着这个简单的 CREATE TABLE
查询 20 分钟了,但我不明白为什么它会抛出错误:
create table `schema_change` (
`schema_change_id` unsigned int not null auto_increment,
`major_release_number` unsigned int not null,
`minor_release_number` unsigned int not null,
`point_release_number` unsigned int not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);
返回的错误是一个基本的语法错误,但我找不到任何不正确的语法:
#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 'unsigned int not null, minor_release_number unsigned int not
null, point_rel' at line 3
我错过了什么?
(使用 MySQL 版本 5.1.73)
UNSIGNED
是类型属性,必须跟在类型名称后面:INT UNSIGNED
,而不是UNSIGNED INT
.
必须在类型后面加上unsigned,因为它修改了int
的类型
create table `schema_change` (
`schema_change_id` int unsigned auto_increment,
`major_release_number` int unsigned not null,
`minor_release_number` int unsigned not null,
`point_release_number` int unsigned not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);
在此处查看实际操作:http://sqlfiddle.com/#!9/685bf/1
我已经盯着这个简单的 CREATE TABLE
查询 20 分钟了,但我不明白为什么它会抛出错误:
create table `schema_change` (
`schema_change_id` unsigned int not null auto_increment,
`major_release_number` unsigned int not null,
`minor_release_number` unsigned int not null,
`point_release_number` unsigned int not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);
返回的错误是一个基本的语法错误,但我找不到任何不正确的语法:
#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 'unsigned int not null, minor_release_number unsigned int not null, point_rel' at line 3
我错过了什么?
(使用 MySQL 版本 5.1.73)
UNSIGNED
是类型属性,必须跟在类型名称后面:INT UNSIGNED
,而不是UNSIGNED INT
.
必须在类型后面加上unsigned,因为它修改了int
create table `schema_change` (
`schema_change_id` int unsigned auto_increment,
`major_release_number` int unsigned not null,
`minor_release_number` int unsigned not null,
`point_release_number` int unsigned not null,
`script_name` varchar(100) not null,
`date_applied` datetime not null,
constraint `pk_schema_change` primary key (
`schema_change_id`
)
);
在此处查看实际操作:http://sqlfiddle.com/#!9/685bf/1