creating primary key based on date

前端 未结 4 597
南方客
南方客 2020-12-07 05:05

I am trying to create a unique ID for each record based on the date the record is created. Example, if the record is created today, I want the key to be 20101130XX where XX

4条回答
  •  借酒劲吻你
    2020-12-07 05:35

    This approach simply won't work because @Charles is true. You can't rely on a timestamp because there's a chance of duplicates (collision).

    Create a simple autoincrement id then save the timestamp too and you'll be happy.

提交回复
热议问题