Exact Numeric data types

These are the data types which store numeric data. This data base stores both natural numbers and fraction values.

Exact numeric data types are:

BIT              :  This data type stores only 2 values. That is it stores only 0 and 1.
TINYINT    :  This data type is used to hold small natural numbers (< 255)
SMALLINT:  Used to hold small natural numbers (< 32,767)
INT              :  This is frequently used data type. Used to hold natural numbers ( <2^31)
BIGINT       :  Not frequently used. It will hold numbers which are very large. This data       
Type is used to hold integer values which requires more storage space           than it needed for INT.

Following data types will be used to hold currency values.

SMALLMONEY  :  This data type can hold up to currency 214,748.3647.
MONEY                :  This data type is generally used in money calculation.

Note: MONEY and SAMLLMONEY data types can hold the accurate to ten thousandth of monetary units.
That is these data types can hold up to 4 digits after the decimal point


Size of the above data types  in bytes is given below:

Data Type
Size of the data type in Bytes
BIT
1 Byte
TINYINT   
1 Byte
SMALLINT
2 Bytes
INT
4 Bytes
BIGINT
8 Bytes
SMALLMONEY
4 Bytes
MONEY
8 Bytes


Following data types will be used to hold the numeric data which with at most precision.

NUMERIC, DECIMAL:  Both numeric and Decimal data types are functionally same.

Syntax for these data types is as follows:

Numeric(P,S)
Decimal(P,S)

P : Precision
S : Scale

Precision indicates the total number of digits in the data
Scale indicates the number digits after the decimal point.


Example: for the value 1234.567 ; Precision is 7 , Scale is 4

S(Scale) is always less than P(Precision).
Note:  Maximum Precision for numeric and Decimal Data types is 38. Default Precision is 18.

Size of the NUMERIC and DECIMAL Data types vary based on the precision ( P ) Values.

Below table contains the sizes of these data types based on precision:

Data Type
Size of the data type in Bytes
1-9
5
10-19
9
20-28
13
29-38
17

This entry was posted in . Bookmark the permalink.

Leave a reply