简体   繁体   English

我应该使用smallint还是numeric(4,0)在SQL Server中存储一年

[英]Should I use smallint or numeric(4,0) to store a year in SQL Server

I have a limited amount of RAM available on my server. 我的服务器上可用的RAM数量有限。 I've read about using smallint to store a year here but I was wondering if using a fixed precision number would be better on Microsoft SQL Server. 我已经读过有关使用smallint在此处存储一年的信息,但我想知道在Microsoft SQL Server上使用固定精度数字是否会更好。

Your data type will take up storage space, not RAM. 您的数据类型将占用存储空间,而不是RAM。 Smallint ranges from -2^15 (-32,768) to 2^15-1 (32,767) so that would probably satisfy your need. Smallint范围从-2 ^ 15(-32,768)到2 ^ 15-1(32,767),因此可能会满足您的需求。

You can see the difference in bytes between decimal/numeric , float/real , and the various ints on MSDN. 您可以在MSDN上看到十进制/数字float / real和各种int之间的字节差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM