I use VARCHAR as the primary key. I want it to automatically increase it (base 62, lower / upper case, numbers). However, the code below does not work (for obvious reasons):
CREATE TABLE IF NOT EXISTS `campaign` ( `account_id` BIGINT(20) NOT NULL, `type` SMALLINT(5) NOT NULL, `id` VARCHAR(16) NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
however this works:
CREATE TABLE IF NOT EXISTS `campaign` ( `account_id` BIGINT(20) NOT NULL, `type` SMALLINT(5) NOT NULL, `id` VARCHAR(16) NOT NULL PRIMARY KEY ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
What is the best way to track id growth? (Since auto_increment does not work). Do I need to create another table containing the current iteration of the ID? Or is there a better way to do this?
EDIT: I want to clarify that I know that using INT is the primary key of auto_increment, it is a logical way. This question is in response to some previous dialogue that I saw. Thanks
mysql primary-key auto-increment
Kenny cason
source share