sql server 2008 r2 中的数字 (18, 0) 是什么

2022-01-16 00:00:00 sql sql-server sql-server-2008-r2

我从该数据类型中找到了一个包含此列的表

I found a table with this a column from this data type

numeric(18, 0)

请问这是什么?以及为什么 018 的意思是

what is that please? and why does 0 and 18 mean

我已经检查过这个问题数字、浮点数和SQL Server 中的小数,但无法理解.

I already check this question Difference between numeric, float and decimal in SQL Server but couldn't understand it.

我可以在该列中添加 (-10) 吗?

can I add (-10) in that column?

我可以在该列中添加所有负数吗?

can I add all negative number in that column?

我可以在该列中添加任何正数吗?

can I add any positive number in that column?

这是我在该列中找到的数据样本

This is a sample of the data I found in that column

100
263
13
2
9
4
3
3
28
15
33
16
135
50
64
60
100
500
150

更新 2是否可以有 -+ ?

Update 2 Is it possible to have - and + ?

推荐答案

第一个值是precision,第二个是scale,所以 18,0 本质上是 18 位数字,小数点后为 0 位.例如,如果您有 18,2,您将有 18 位数字,其中两位将在小数点后...

The first value is the precision and the second is the scale, so 18,0 is essentially 18 digits with 0 digits after the decimal place. If you had 18,2 for example, you would have 18 digits, two of which would come after the decimal...

18,2 示例:1234567890123456.12

example of 18,2: 1234567890123456.12

numericdecimal 之间没有 功能 区别,除了名称和我想我记得首先是数字,如较早的版本.

There is no functional difference between numeric and decimal, other that the name and I think I recall that numeric came first, as in an earlier version.

然后回答,我可以在该列中添加 (-10) 吗?" - 可以.

And to answer, "can I add (-10) in that column?" - Yes, you can.

相关文章