Last active
August 17, 2017 13:48
-
-
Save ninodafonte/6539074 to your computer and use it in GitHub Desktop.
Create autoincrement with a specific number (date) #postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment