I want to create a table name Users where I should have have columns User
, cookieID
, sessionID
, Geo
and then I want to first three columns to have some random unique value assigned automatically. I tried to make all three columns AUTO_INCREMENT
with User
column PRIMARY
and 'cookieIDand
sessionIDcolumn
UNIQUE`. The SQL code is:
CREATE TABLE `users` ( `User` VARCHAR(20) NOT NULL AUTO_INCREMENT ,
`cookieID` INT(20) NULL DEFAULT NULL AUTO_INCREMENT ,
`sessionID` INT(20) NULL DEFAULT NULL AUTO_INCREMENT ,
`Geo` VARCHAR(30) NULL DEFAULT NULL ,
PRIMARY KEY (`User`), UNIQUE (`cookieID`), UNIQUE (`sessionID`), UNIQUE (`Geo`));
But, it did not work because only one column can be declared as AUTO_INCREMENT
which must be PRIMARY
.
What is the another approach to do this?