0

I declared profile id as foriegn key and also give auto increment to it in personprofile table.In address table i have given address id as auto increment where I did a mistake?

    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
Vinit Mapari
  • 439
  • 3
  • 7
  • 15

0 Answers0