1

I'm confused about how to generate a unique number as a order number which is not replicated in my mysql database. is there any function or class to generate unique order number

Thanks in advance.

Om Komawar
  • 251
  • 3
  • 19
  • You could use the row id after you insert it into your database -- that way the db will handle keeping it unique. – Buddy Sep 04 '15 at 03:58
  • 1
    there is a UUID class that does that sort of things. otherwise sqlite maintain a unique id of all entries. – njzk2 Sep 04 '15 at 03:59
  • Thanks Guys i Appreciate the reply that helped me generate unique ids or order no – Om Komawar Sep 04 '15 at 04:58

1 Answers1

0

Here is a little example of how to use UUID, UUID can generate a unique identifier for you

stallianz
  • 176
  • 1
  • 17
  • The String it generates is very big. Is there any other way!!?? – Rajnish Sharma Oct 20 '20 at 18:01
  • @RajnishSharma UUID by definition is supposed to be 16-byte. see https://stackoverflow.com/a/4267848/2657670 you can try https://stackoverflow.com/a/45055701/2657670 – stallianz Oct 23 '20 at 13:41