错误1075:表定义不正确;只能有一个自动列,必须将其定义为键

时间:2018-06-11 13:17:01

标签: mysql

我将profile id声明为foriegn键,并在personprofile表中给它自动增加。在地址表中我给地址id作为自动增量 在哪里我犯了错误?

    Executing SQL script in server
    ERROR: Error 1075: Incorrect table definition; 
there can be only one auto column and it must be defined as a key
    SQL Code:
            -- -----------------------------------------------------
            -- Table `mydb`.`Addresses`
            -- -----------------------------------------------------
            CREATE TABLE IF NOT EXISTS `mydb`.`Addresses` (
              `ProfileId` INT NOT NULL,
              `AddressId` INT NOT NULL AUTO_INCREMENT,
              `AddressTypes` VARCHAR(45) NOT NULL,
              `Address-L1` VARCHAR(45) NOT NULL,
              `Address-L2` VARCHAR(45) NOT NULL,
              `Locality` VARCHAR(45) NOT NULL,
              `City` VARCHAR(45) NOT NULL,
              `State` VARCHAR(45) NOT NULL,
              `Country` VARCHAR(45) NOT NULL,
              `PostalCode` INT NOT NULL,
              INDEX `fk_addresses_personprofile_idx` (`ProfileId` ASC),
              CONSTRAINT `fk_addresses_personprofile`
                FOREIGN KEY (`ProfileId`)
                REFERENCES `mydb`.`personprofile` (`ProfileId`)
                ON DELETE NO ACTION
                ON UPDATE NO ACTION)
            ENGINE = InnoDB

0 个答案:

没有答案