Collection Contents Index Character data types Money data types pdf/chap7.pdf

Reference Manual
   CHAPTER 7. SQL Data Types     

Numeric data types


Function 

For storing numerical data.

Notes 

Compatibility 

Top of page  BIGINT data type [Numeric]

Function 

A signed 64-bit integer.

Syntax 

[ UNSIGNED ] BIGINT

Usage 

The BIGINT data type is an exact numeric data type: its accuracy is preserved after arithmetic operations.

A BIGINT value requires 8 bytes of storage.

The range for signed BIGINT values is from ( -2e63 + 1 ) to ( +2e63 -1 ).

The range for unsigned BIGINT values is from 0 to ( 2e64 - 1 ).

By default, the data type is signed.

Standards and compatibility 

See also 

INT or INTEGER data type

TINYINT data type

SMALLINT data type

Top of page  DECIMAL data type [Numeric]

Function 

A decimal number with precision total digits and with scale of the digits after the decimal point.

Syntax 

{ DECIMAL | DEC } [ ( precision [ , scale ] ) ]

Usage 

The DECIMAL data type is an exact numeric data type; its accuracy is preserved to the least significant digit after arithmetic operations.

The storage required for a decimal number can be estimated as:

2 + int( ( before+1 ) / 2 ) + int( ( after + 1 )/2 )

where int takes the integer portion of its argument, and before and after are the number of significant digits before and after the decimal point. The storage is based on the value being stored, not on the maximum precision and scale allowed in the column.

Parameters 

precision     An integer expression that specifies the number of digits in the expression. The default setting is 30.

scale     An integer expression that specifies the number of digits after the decimal point. The default setting is 6.

The defaults can be changed by setting database options. For information, see PRECISION option and SCALE option.

Standards and compatibility 

See also 

FLOAT data type

REAL data type

DOUBLE data type

Top of page  DOUBLE data type [Numeric]

Function 

A double-precision floating-point number.

Syntax 

DOUBLE [ PRECISION ]

Usage 

The DOUBLE data type holds a double-precision floating point number.

It is an approximate numeric data type; subject to roundoff errors after arithmetic operations. The approximate nature of DOUBLE values means that queries using equalities should generally be avoided when comparing DOUBLE values.

DOUBLE values require 8 bytes of storage.

The range of values is 2.22507385850721e-308 to 1.79769313486231e+308. Values held as DOUBLE are accurate to 15 significant digits, but may be subject to round-off error beyond the fifteenth digit.

Standards and compatibility 

See also 

FLOAT data type

REAL data type

DECIMAL data type

Top of page  FLOAT data type [Numeric]

Function 

A floating point number, which may be single or double precision.

Syntax 

FLOAT [ ( precision ) ]

Usage 

When a column is created using the FLOAT ( precision ) data type, columns on all platforms are guaranteed to hold the values to at least the specified minimum precision. In contrast, REAL and DOUBLE do not guarantee a platform-independent minimum precision.

If precision is not supplied, the FLOAT data type is a single precision floating point number, equivalent to the REAL data type, and requires 4 bytes of storage.

If precision is supplied, the FLOAT data type is either single or double precision, depending on the value of precision specified. The cutoff between REAL and DOUBLE is platform-dependent. Single precision FLOATs require 4 bytes of storage, and double precision FLOATs require 8 bytes.

The FLOAT data type is an approximate numeric data type. It is subject to roundoff errors after arithmetic operations. The approximate nature of FLOAT values means that queries using equalities should generally be avoided when comparing FLOAT values.

Parameters 

precision     An integer expression that specifies the number of places after the decimal.

Standards and compatibility 

See also 

DECIMAL data type

REAL data type

DOUBLE data type

Top of page  INT or INTEGER data type [Numeric]

Function 

An integer value requiring 4 bytes of storage.

Syntax 

[ UNSIGNED ] { INT | INTEGER }

Usage 

The INTEGER data type is an exact numeric data type; its accuracy is preserved after arithmetic operations.

If you specify UNSIGNED; the integer can never be assigned a negative number. By default, the data type is signed.

The range for signed integers is from ( -2e31 + 1 ) to ( +2e31 -1 ).

The range for unsigned integers is from 0 to ( 2e32 - 1 ).

Standards and compatibility 

See also 

BIGINT data type

TINYINT data type

Top of page  NUMERIC data type [Numeric]

Function 

Same as DECIMAL.

Syntax 

NUMERIC [ ( precision [ , scale ] ) ]

Usage 

The NUMERIC data type is an exact numeric data type; its accuracy is preserved to the least significant digit after arithmetic operations.

The storage required for a decimal number can be estimated as:

2 + int( (before+1) / 2 ) + int( (after+1)/2 )

where int takes the integer portion of its argument, and before and after are the number of significant digits before and after the decimal point. The storage is based on the value being stored, not on the maximum precision and scale allowed in the column.

Parameters 

precision      An integer expression that specifies the number of digits in the expression. The default value is 30.

scale     An integer expression that specifies the number of digits after the decimal point. The default value is 6.

The defaults can be changed by setting database options. For information, see PRECISION option and SCALE option.

Standards and compatibility 

See also 

FLOAT data type

REAL data type

DOUBLE data type

Top of page  REAL data type [Numeric]

Function 

A single-precision floating-point number stored in 4 bytes.

Syntax 

REAL

Usage 

The REAL data type is an approximate numeric data type; it is subject to roundoff errors after arithmetic operations.

The range of values is 1.175495e-38 to 3.402823e+38. Values held as REAL are accurate to 10 significant digits, but may be subject to round-off error beyond the sixth digit.

The approximate nature of REAL values means that queries using equalities should generally be avoided when comparing REAL values

Standards and compatibility 

Top of page  SMALLINT data type [Numeric]

Function 

Integer value requiring 2 bytes of storage.

Syntax 

[ UNSIGNED ] SMALLINT

Usage 

The SMALLINT data type is an exact numeric data type; its accuracy is preserved after arithmetic operations. It requires 2 bytes of storage.

The range for signed SMALLINT values is from -32768 to + 32767.

The range for unsigned SMALLINT values is from zero to 65535.

Standards and compatibility 

See also 

INT or INTEGER data type

TINYINT data type

BIGINT data type

Top of page  TINYINT data type [Numeric]

Function 

Unsigned integer, requiring 1 byte of storage.

Syntax 

[ UNSIGNED ] TINYINT

Usage 

The TINYINT data type is an exact numeric data type; its accuracy is preserved after arithmetic operations.

You can explicitly specify TINYINT as UNSIGNED, but the UNSIGNED modifier has no effect as the type is always unsigned.

The range for TINYINT values is from zero to 255.

Standards and compatibility 

See also 

BIGINT data type

TINYINT data type

SMALLINT data type

Top of page  

Collection Contents Index Character data types Money data types pdf/chap7.pdf