본문 바로가기

ERRORMESSAGE

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

728x90

- 테이블 생성시 이와 같은 에러가 나는이유 -> primaryKey로 지정하였나 확인 !!

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

 

 

AUTO_INCREMENT는 항상 기본키(primary key)로 지정되어야 한다 
->  not null은 없어도 문법적 오류를 발생시키지 않지만 primary key가 없으면 문법적 오류를 발생시킨다.

 

예시1)

create table user(
	idx int not null AUTO_INCREMENT
	PRIMARY KEY (idx)
);

 

예시2)

create table user(
	idx int not null AUTO_INCREMENT PRIMARY KEY
);

 

728x90