这取决于几个因素。首先,您的数据收集可能有多大,我们谈论的是数千个 UID 还是数百万个?如果您不担心项目的规模,然后尝试找到最小的容器(一个大整数),那么您会更担心能够随着变化进行扩展。
So now you need to choose VarChar of a reasonable size which will take any format of UID and be happy- this includes leading zeros and bigInt which is easier to sanitise for but unfriendly to leading zeros and letters.
If you know that the UID is always a non-leading zero or zero padded number then you can get slightly better security by sanitising by way of casting to type. That and size are all the benefits of bigInt.
VarChar has the downfall of size - you need to know the biggest UID length before you start but leading zeros, letters and other unexpected content can be handled with the small exception that you are now cleaning a string.
From a programming point of view it makes very little odds as a UID is just a label that is unique. With an index on it I should not imagine that there is any speed difference in MySQL at least not with the common engines it might be using.
So best is simply a product of what you need most from the data.