开发者

Which type should I use to store an ID card in database?

What is the best way to store an ID card number (8 digits) in a d开发者_开发技巧atabase? Integer or VARCHAR(8)? Thanks. I am using PostgreSQL.


I will assume MySQL for this question, as you failed to state any details.

Since it's a numeric value, not a string, I recommend using a numeric type. You can make the best use of space by using the narrowest type that's wide enough in MySQL, which is DECIMAL(8).

Also make the column UNSIGNED, and possibly use ZEROFILL.


Unsigned Integer should be large enough to handle 99999999 since it's max value is 4294967295. Integer should also be faster when searching and will also be a smaller storage data type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜