Auto Increment varchar in MySQL

前端 未结 4 916
眼角桃花
眼角桃花 2021-01-19 07:07

Is there a way to set primary key auto increment, type of varchar in mySql?

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 07:44

    NONE. So far, AUTO_INCREMENT can be set for INT only. It needs to have your own logic to do that. eg,

    • Get Last ID
    • Get the INT part within the string
    • Increment the value
    • Concatenate
    • Save to DB

提交回复
热议问题