SQL Server 資料類型 float, real, money, decimal, numeric

來源:互聯網
上載者:User

Float and Real 

Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly. The ISO synonym for real is float(24).

 
Data type Range Storage

float

- 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308

Depends on the value of n

real

- 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38

4 Byt

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.

n value Precision Storage size

1-24

7 digits

4 bytes

25-53

15 digits

8 bytes

 

 

Decimal and Numeric

Numeric data types that have fixed precision and scale.

( p,  s)] and  numeric( p,  s)]

are dec and dec(ps)numeric is functionally equivalent to decimal.

 

(scale)

. 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.

 

decimalFixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1. The ISO synonyms for decimalp (precision) The maximum total number of decimal digits that can 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.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

 

Money and SmallMoney

Data types that represent monetary or currency values.

The  money and  smallmoney data types are accurate to a ten-thousandth of the monetary units that they represent.
Data type   Range Storage

money

 

-922,337,203,685,477.5808 to 922,337,203,685,477.5807

8 bytes

smallmoney

 

- 214,748.3648 to 214,748.3647

4 bytes

 

 

FLOAT   類型表示浮點數(非精確數),可以接收以科學記號標記法表示的浮點數。FLOAT   類型比較特殊,定義時甚至可以給它指定精度。在實際應用中應該盡量避免使用

FLOAT作為 等於或者 不等於條件中,在 大於或者 小於條件中使用沒有問題。

錢相關的建議使用money資料類型 
decimal建議在資料較大,或要求精度較高,或對計算結果進行精度控制時使用。decimal和numeric基本沒有什麼不同。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.