ERROR 1075 (42000) at line 1: Incorrect table definition; there can be only one auto column and it must be defined as a key 메세지가 떠요.

처음 입력한 sql 구문

CREATE TABLE items (
    id INT AUTO_INCREMENT,
    name varchar(255),
    description varchar(255),
    price INT,
    discount INT,
    inventory INT,
    image varchar(255),
    
)

잘못된 부분

PRIMARY KEY (id) 를 맨 마지막 줄에 넣지 않아서 발생한 에러.
it must be defined as a key 가 나름의 힌트가 되지 않았나 싶다.
즉, PRIMARY KEY를 제대로 지정해줘야 된다는 뜻.

최종 완성

CREATE TABLE items (
    id INT AUTO_INCREMENT,
    name varchar(255),
    description varchar(255),
    price INT,
    discount INT,
    inventory INT,
    image varchar(255),
    PRIMARY KEY (id)
)

sudo mysql -u root -p < schema.sql -Dxxxxxxx를 입력해주면 정상적으로 테이블이 들어갈 것이다.
xxxxxxx에는 데이터베이스 이름을 넣어주면 된다.

profile
피트는 구덩이라는 뜻이다 구덩이를 파다보면 좋은 것이 나오겠지 (아싸 벡스룬)

0개의 댓글

Powered by GraphCDN, the GraphQL CDN