Why do many systems use String as ID, instead of Int type?

Why do many systems use String (char) as ID, instead of Int? For example, SnowFlakeId, is an integer, but many systems use String to store

Mar.28,2021

A better explanation


first of all, there is no stipulation that String cannot do id,int and it is not a convention.

finally, UUID understands that that thing is already String, 's impression that the default ID type of sql server is this kind of UUID


the range of int types is limited, it is embarrassing to exceed it, but the range of using strings is wide.


do you want to hear the truth or the lie?
the myth is that both String and int are saved as byte [] in the server. At this time, you can compare the size of the string directly by comparing the two byte [], while int needs to convert byte [] to int before it can be compared. From this point of view, the performance of String is better than that of int.
the truth is GUID. Even if it becomes a String, in its lifetime, I don't bother to change it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b358ba-2bfb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b358ba-2bfb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?