ninodafonte
9/12/2013 - 3:09 PM

Create autoincrement with a specific number (date) #postgres

Create autoincrement with a specific number (date) #postgres

set @autoincrementValue = (SELECT DATE_FORMAT(NOW(), '%y%m%d') * 10000); 
SET @s = CONCAT("alter table NameOfYourTable auto_increment=", @autoincrementValue); 
PREPARE stmt FROM @s; 
EXECUTE stmt; 
DEALLOCATE PREPARE stmt;