Wednesday, May 22, 2013

[SQL][Solved] #1075 - Incorrect table definition

Using This SQL statement, I get this error #1075:
CREATE TABLE users(
user_id INT AUTO_INCREMENT ,
first_name VARCHAR( 20 ) ,
last_name VARCHAR( 30 ) ,
email VARCHAR( 50 ) ,
facebook_name VARCHAR( 100 ) ,
twitter_handle VARCHAR( 20 )
);
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

By set the auto-increment column to Primary Key, 
the error fixed:
CREATE TABLE users(
user_id INT AUTO_INCREMENT PRIMARY KEY ,
first_name VARCHAR( 20 ) ,
last_name VARCHAR( 30 ) ,
email VARCHAR( 50 ) ,
facebook_name VARCHAR( 100 ) ,
twitter_handle VARCHAR( 20 )
)
Your SQL query has been executed successfully ( Query took 0.0660 sec )

No comments :

Post a Comment