numeric and int in sql server
类型映射
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings
C#关键字
decimal
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/decimal
The decimal
keyword indicates a 128-bit data type.
Compared to other floating-point types, the decimal
type has more precision and a smaller range, which makes it appropriate for financial and monetary calculations.
The approximate range and precision for the decimal
type are shown in the following table.
取值范围(-7.9 x 1028 to 7.9 x 1028) / (100 to 1028)
精度28-29 significant digits
int
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int
int
denotes an integral type that stores values according to the size and range shown in the following table.
取值范围-2,147,483,648 to 2,147,483,647
大小Signed 32-bit integer
SQL Server中
https://docs.microsoft.com/en-us/sql/t-sql/data-types/decimal-and-numeric-transact-sql
Numeric data types that have fixed precision and scale. Decimal and numeric are synonyms and can be used interchangeably.
decimal[ (p[ ,s] )] and numeric[ (p[ ,s] )]
Fixed
precision and scale numbers.
When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1.
The ISO synonyms for decimal are dec and dec(p, s).
numeric is functionally equivalent to decimal.
p (precision)
The maximum total number of decimal digits that will be stored, both to the left and to the right of the decimal point.
The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.
s (scale)
The number of decimal digits that will be 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.
The maximum number of decimal digits that can be stored to the right of the decimal point.
Scale must be a value from 0 through p.
Scale can be specified only if precision is specified.
The default scale is 0; therefore, 0 <= s <= p.
Maximum storage sizes vary, based on the precision.
Example
numeric(18,2)的取值范围
最大9999999999999999.99 小数点右边两位数字,左边16位数字
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了