N
N
NZ012021-09-10 08:57:40
MySQL
NZ01, 2021-09-10 08:57:40

How to generate a unique user ID?

How to create unique identifiers for users in MySQL database?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
idShura, 2021-09-10
@idShura

Hang AUTO_INCREMENT on the field and create a UNIQUE INDEX

B
BorLaze, 2021-09-10
@BorLaze

What does "unique identifier" mean? primary key? :-)
If something is temporary (the session is there or something like that), then why is the UUID not suitable?

T
ThunderCat, 2021-09-10
@ThunderCat

Depends on the application. For data binding inside the database, an auto-incrementing primary key is quite suitable, and for a URL or an intra-service address, you can use a login or, if the login is not suitable, generate a hash from the microtime, for example, and write it as an identifier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question