MYSQL建表时报ERROR 1064 (42000),急求解答

初接触MYSQL,执行建表语句,报ERROR 1064 (42000):错误
create table forname
(
id int not null auto_increment,
first_name varchar(30) not null,
last_name varchar(30) not null
)
ERROR 1064 (42000): 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 'm' at
line 6

请了解的同学指点下,谢谢额。。

id int not null auto_increment,
改成 id int primary key auto_increment,
因为auto_increment只能加在主键
但是错误提示好奇怪,追问

貌似还是不行啊,执行了如下:
mysql> create table forname
-> (
-> id int not null primary key auto_increment,
-> first_name varchar(30) not null,
-> last_name varchar(30) not null
-> );
ERROR 1064 (42000): 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 'm' at
line 6

追答

朋友,你没按我说的改哦,就用这个吧
create table forname
(
id int primary key auto_increment,
first_name varchar(30) not null,
last_name varchar(30) not null
)
-----------------
你id的 not null没去掉,

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答