What does “numeric precision radix” mean in the SQL Server metadata?

允我心安 提交于 2019-12-05 09:23:19

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

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

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.

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.

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.

See wiki link here

SQL Fiddle

MS SQL Server 2008 Schema Setup:

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

Query 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) |
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!