Integer vs String in database

前端 未结 16 641
后悔当初
后悔当初 2020-12-05 13:42

When defining datatypes in a database, I have always had a problem with choosing whether to use integers or strings to store certain \'numerical\' data.

Say I am bui

16条回答
  •  心在旅途
    2020-12-05 14:22

    in my opinion for postal codes you have to use strings, because you can have postal codes that stards with zeros (09100) and if you use integers it would be 9100: sorting is not a problem, because there is still an alphabetical order ('09100' comes before '09101'). For Storing file numbers I would expect an interger, so you don't have any problem in incresing / decreasing its number. So integer vs strings depends upon the use you make!

提交回复
热议问题