2

I have a problem when I run this SQL query:

 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 )

The error I keep running into is the following:

Incorrect table definition;
there can be only one auto column and it must be defined as a key

3
  • Try defining the auto increment column as a key ... Commented May 18, 2015 at 17:30
  • 2
    In the future, please add the tag of the specific database software you are using. Commented May 18, 2015 at 17:32
  • Thanks for the sugestion. I`m using phpmyadmin Commented May 18, 2015 at 17:35

1 Answer 1

1

Try this

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
) 

OR 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 
    ) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.