Integer types

Adaptive Server provides three exact numeric datatypes to store integers: int (or integer), smallint, and tinyint. Choose the integer type based on the expected size of the numbers to be stored. Internal storage size varies by type, as shown in Table 1-5:

Table 1-5: Integer datatypes

Datatype

Stores

Bytes of storage

int[eger]

Whole numbers between-231 and 231 - 1 (-2,147,483,648 and 2,147,483,647), inclusive.

4

smallint

Whole numbers between -215 and 215 -1 (-32,768 and 32,767), inclusive.

2

tinyint

Whole numbers between 0 and 255, inclusive. (Negative numbers are not permitted.)

1

Entering integer data

Enter integer data as a string of digits without commas. Integer data can include a decimal point as long as all digits to the right of the decimal point are zeros. The smallint and integer datatypes can be preceded by an optional plus or minus sign. The tinyint datatype can be preceded by an optional plus sign.

Table 1-6 shows some valid entries for a column with a datatype of integer and indicates how isql displays these values:

Table 1-6: Valid integer values

Value entered

Value displayed

2

2

+2

2

-2

-2

2.

2

2.000

2

Table 1-7 lists some invalid entries for an integer column:

Table 1-7: Invalid integer values

Value entered

Type of error

2,000

Commas not allowed.

2-

Minus sign should precede digits.

3.45

Digits to the right of the decimal point are nonzero digits.