본문 바로가기
카테고리 없음

MS SQL - Numeric, Decimal 차이점.

by 지환이아빠 2022. 3. 1.
반응형

MS-SQL 에서 Numeric 과 Decimal 은 기능상으로 동일하다고 되어 있다.

MS 에서 이렇게 모호한 설명을 제공한 탓에 Numeric 과 Decimal 에 대한 논의가 많다.

 

어떠한 논의가 있느냐 하면...

 

1. 정말 동일하다. (MS-SQL 에서는 둘을 정말 동일하게 구현했다는 주장).

2. MS-SQL에서는 기존에 Numeric 으로 구현했는데, 표준에 Decimal 이 있어서, Decimal 이 살짝 끼어 들어온 셈이다.

3. Sybase 에서 넘어온 구현과 MS-SQL 구현이 있다..

 

개인적으로는

표준에 의하면 둘은 약간의 차이가 있을 수 있는데, 현재 MS-SQL 의 구현은 Numeric과 Decimal 이 동일하게 구현된 것 같습니다.

 

아래는 ISO Standard 에 기술된 내용입니다.  

 

 

ISO/IEC 9075-2:2003 (E)
6.1 <data type>

....

....

<exact numeric type> ::=
NUMERIC [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
| DECIMAL [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
| DEC [ <left paren> <precision> [ <comma> <scale> ] <right paren> ]
| SMALLINT
| INTEGER
| INT
| BIGINT
 ...

...

...

20) For the <exact numeric type>s DECIMAL and NUMERIC:
a) The maximum value of <precision> is implementation-defined. <precision> shall not be greater than
this value.
b) The maximum value of <scale> is implementation-defined. <scale> shall not be greater than this
maximum value.
21) NUMERIC specifies the data type exact numeric, with the decimal precision and scale specified by the
<precision> and <scale>.
22) DECIMAL specifies the data type exact numeric, with the decimal scale specified by the <scale> and the
implementation-defined decimal precision equal to or greater than the value of the specified <precision>.

 

구현하기에 따라서는 NUMERIC 은 지정한 정밀도와 크기에 정확하게 맞아 떨어지게 구현해야 하지만, DECIMAL 은 NUMERIC 보다 좀 더 넓은 범위를 표현하게 구현할 수도 있다는 것 같습니다.

 

출처 : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=shwsun&logNo=40172515906

 

MS SQL - Numeric, Decimal 차이점.

MS-SQL 에서 Numeric 과 Decimal 은 기능상으로 동일하다고 되어 있다. MS 에서 이렇게 모호한 설...

blog.naver.com

 

반응형

댓글