ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

sqlserver

2021-09-26 18:03:44  阅读:234  来源: 互联网

标签:decimal float sqlserver number value precision byte


基本数据类型

  • 整形数据:
bigint 8 byte
int 4 byte
smallint 2 byte
tinyint 1 byte

C#定义的整形数据

long 8 byte
ulong 8 byte
int 4 byte
uint 4 byte
short 2 byte
ushort 2 byte
sbyte 1 byte
byte 1 byte

是能一一对应上的。

  • 浮点类型:
    | | |
    | ------------ | ------------ |
    | real | |
    | | |

float [ (n) ] Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53. The default value of n is 53.

mantissa n.对数
notation n.符号

type n
float/real 1~24 4 byte
float 24~53 8 byte

可以发现与C#中的浮点类一样。因为两者都是符合ISO规范的。

  • 精确计数
    decimal[(p[,s])]
    numeric[(p[,s])]

p (precision)
The maximum total number of decimal digits to be stored. This number includes both the left and the right sides of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.

p是指数字位数,包括整数和小数。值域为[1,38]。默认为18。

s (scale)
The number of decimal digits that are stored to the right of the decimal point. This number is subtracted from p to determine the maximum number of digits to the left of the decimal point. Scale must be a value from 0 through p, and can only be specified if precision is specified. The default scale is 0 and so 0 <= s <= p. Maximum storage sizes vary, based on the precision.

s是指整数位数,值域[0,p],可以不指定。

Precision Storage bytes
1 - 9 5
10-19 9
20-28 13
29-38 17
  • 货币计算
smallmoney 8 byte
money 4 byte

储存时不会储存货币符号,只会储存数值。

标签:decimal,float,sqlserver,number,value,precision,byte
来源: https://www.cnblogs.com/none323/p/15190170.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有