Reputation: 11
While creating table in mysql administrator :-
CREATE TABLE `db`.`product` (
`product_nm` VARCHAR(45) NOT NULL,
`count` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`product_nm`)
)
ENGINE = InnoDB;
We came across error 1075 for auto increment of count variable. Please suggest another way of doing same without error in mysql administrator.
Upvotes: 0
Views: 69
Reputation: 37023
You can't have auto increment field without specifying it as primary key.
If You want to have an auto-Incrementing column that is not the PRIMARY KEY, then there must be an index (key) on it, like below:
CREATE TABLE members (
`product_nm` VARCHAR(45) NOT NULL,
`count` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`product_nm`)
KEY (count)
) ENGINE = InnoDB;
Upvotes: 1