简体   繁体   中英

In what cases should I use UUID as primary key in Django models

What are advantages and disadvantages of UUID field?

When should I use it as a primary key? When should I use default primary key?

My table has many rows. Is it possible that max value of default primary key will be exceeded?

I use PostgreSQL.

Primary Key -

It is an auto-increment unique key which is created by database engine when we create a new record each time to the table.

UUID -

It is unique too but it is unique in " the whole universe ", not guaranteed unique but practically unique . Like when we want create a ticket based environment to solve customer issues then we must generate a ticket_id by UUID(because its unique and it is combination of random numbers).

If you want to go deep into it then check this awesome blog here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM