#1067 - Invalid default value for 'bonusid' how can i fix this error?

后端 未结 3 1320
面向向阳花
面向向阳花 2021-01-14 06:03

SQL query:

CREATE TABLE bonus(
bonusid INT( 10 ) DEFAULT  \'0\' NOT NULL AUTO_INCREMENT ,
empid INT( 10 ) DEFAULT  \'0\' NOT NULL ,
datebonus DATE DEFAULT  \         


        
3条回答
  •  执笔经年
    2021-01-14 07:05

    Even though the bonusid column is NOT NULL - you don't have to specify a default value if it has the special auto_increment option when you create the table.

    Try As follows:

    CREATE TABLE bonus(
    bonusid INT( 10 ) NOT NULL AUTO_INCREMENT ,
    empid INT( 10 ) DEFAULT  '0' NOT NULL ,
    datebonus DATE DEFAULT  '0000-00-00' NOT NULL ,
    bonuspayment VARCHAR( 200 ) NOT NULL ,
    note TEXT NOT NULL ,
    PRIMARY KEY ( bonusid )
    );
    

    FIDDLE DEMO HERE

提交回复
热议问题