运行此SQL查询时遇到问题:
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL )
我一直遇到的错误如下:
表定义不正确;
只能有一个自动列,必须将其定义为键
答案 0 :(得分:1)
试试这个
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL ,
primary key (id) //specify id as primary key will sort out the error..try
)
或尝试
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL
)