Integer vs String in database

前端 未结 16 613
后悔当初
后悔当初 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:34

    Postcodes are strings. For some comtries, those strings may consist onl of numeric digits, but that doesn't make them integers. And sooner or later your potal system will run out of digits and decide to start using letters as well. If your database uses integers for the postcode field, you will be in deep doo-doo.

    Bottom line - if you don't do arithmetic on it, it's probably not really a number.

提交回复
热议问题