There can be only one auto column

前端 未结 4 1658
闹比i
闹比i 2020-12-13 03:29

How do I correct the error from MySQL \'you can only have one auto increment column\'.

CREATE TABLE book (
   id INT AUTO_INCREMENT NOT NULL,
   accepted_ter         


        
4条回答
  •  情书的邮戳
    2020-12-13 03:53

    The full error message sounds:

    ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

    So add primary key to the auto_increment field:

    CREATE TABLE book (
       id INT AUTO_INCREMENT primary key NOT NULL,
       accepted_terms BIT(1) NOT NULL,
       accepted_privacy BIT(1) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

提交回复
热议问题