Is it worth the trouble to use tinyint instead of int for SqlServer lookup tables?

前端 未结 5 1923
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 11:56

When designing a lookup table (enum) in SqlServer 2005, if you know the number of entries will never get very high, should you use tinyint instead of int? I\'m most concerned a

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 12:44

    Any other gotchas?

    I'm not sure if this is the kind of "gotcha" you mean, but I've run into situations where using a datetime instead of a smalldatetime gave incorrect functional behavior, because the lower precision smalldatetime didn't compare as equivalent to the higher precision datetime for two dates that were otherwise "the same".

    There's no chance of that happening here, since a tinyint / smallint / int / bigint will all compare as identical for the same numeric integer value. So you're obviously safe on that count, not that it answers your question exactly.

提交回复
热议问题