什么是“数字精度基数"?在SQL Server元数据中是什么意思? [英] What does "numeric precision radix" mean in the SQL Server metadata?

查看:567
本文介绍了什么是“数字精度基数"?在SQL Server元数据中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览SQL Server Management Studio对象资源管理器:元数据.在TempDb>视图>系统视图>列对象下,我找到:数字精度基数".我知道基数是什么意思(二进制,十进制,十六进制等),数字精度是什么意思(数字表示中有多少个数字,小数位数:小数点后有多少个数字).

I am browsing the SQL Server Management Studio Object Explorer: the metadata. Under the TempDb > Views > System Views > Columns object I find: "Numeric Precision Radix". I know what radix means (binary, decimal, hexidecimal, etc) and what Numeric Precision means (how many digits are in the representation of the number, and Scale: how many digits are after the radix point).

但是元数据自身(数字精度)如何具有基数(编码系统)?就像说油漆的CAN是什么颜色?

But how can the metadata itself (Numeric Precision) have a Radix (system of encoding)? It is like saying what color is the CAN of paint?

为什么我在任何地方都找不到该短语的描述?谢谢.

And why can't I find a description of this phrase anywhere? Thank you.

推荐答案

我相信Numeric_Precision_Radix是在SQL-99标准指定的Information_Schema.Columns表中指定的.

I believe that Numeric_Precision_Radix is specified in the Information_Schema.Columns table as specified by the SQL-99 standard.

每个DBMS都不同. 根据此链接,它指定为:

It will be different for each DBMS. according to this link it is specified as:

如果data_type标识数字类型,则此列指示 将numerical_precision和numeric_scale列中的值作为基础 表达.该值为2或10.对于所有其他数据类型, 此列为空.

If data_type identifies a numeric type, this column indicates in which base the values in the columns numeric_precision and numeric_scale are expressed. The value is either 2 or 10. For all other data types, this column is null.

对于SQL Server,intmoneydecimal为10,float&为2. real.参见下面的示例,其中对于浮点数,基数为2,精度为53,这意味着它精确到53位信息.

For SQL Server it is 10 for int, money and decimal and 2 for float & real. See below for example where for float where the radix is 2 and the precision is 53, meaning that the it is precise to 53 bits of information.

换句话说,对于int精度,用10乘以10的幂表示,但对于实际精度,用2乘以53的幂表示.

In other words for int precision is expressed in terms 10 to the power of 10 but for real it is expressed as 2 to the power of 53.

请参见Wiki 在此处链接

SQL小提琴

MS SQL Server 2008架构设置:

CREATE TABLE MyRadix
(
    aInt int,
    bFloat float,
    cMoney Money,
    dDecimal Decimal(12,10),
    eReal Real
)

查询1 :

SELECT COLUMN_NAME, DATA_TYPE, NUMERIC_PRECISION_RADIX, NUMERIC_PRECISION, NUMERIC_SCALE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyRAdix'

结果 :

Results:

| COLUMN_NAME | DATA_TYPE | NUMERIC_PRECISION_RADIX | NUMERIC_PRECISION | NUMERIC_SCALE |
|-------------|-----------|-------------------------|-------------------|---------------|
|        aInt |       int |                      10 |                10 |             0 |
|      bFloat |     float |                       2 |                53 |        (null) |
|      cMoney |     money |                      10 |                19 |             4 |
|    dDecimal |   decimal |                      10 |                12 |            10 |
|       eReal |      real |                       2 |                24 |        (null) |

这篇关于什么是“数字精度基数"?在SQL Server元数据中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆