Range and storage size

Table 1-2 lists the system-supplied datatypes and their synonyms and provides information about the range of valid values and storage size for each. For simplicity, the datatypes are printed in lowercase characters, although Adaptive Server allows you to use either uppercase or lowercase characters for system datatypes. User-defined datatypes, such as timestamp, are case sensitive. Most Adaptive Server-supplied datatypes are not reserved words and can be used to name other objects.

Table 1-2: Range and storage size for system datatypes

Datatypes

Synonyms

Range

Bytes of storage

Exact numeric datatypes

tinyint

0 to 255

1

smallint

-215 (-32,768) to 215 -1 (32,767)

2

int

integer

-231 (-2,147,483,648) to 231 -1 (2,147,483,647)

4

numeric (p, s)

-1038 to 1038 -1

2 to 17

decimal (p, s)

dec

-1038 to 1038 -1

2 to 17

Approximate numeric datatypes

float (precision)

Machine dependent

4 or 8

double precision

Machine dependent

8

real

Machine dependent

4

Money datatypes

smallmoney

-214,748.3648 to 214,748.3647

4

money

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

8

Date/time datatypes

smalldatetime

January 1, 1900 to June 6, 2079

4

datetime

January 1, 1753 to December 31, 9999

8

date

January 1 0001 to December 31, 9999

4

time

00:00:00:000 to 23:59:59:999

4

Character datatypes

char(n)

character

Determined by your server's logical page size

n

varchar(n)

char[acter] varying

Determined by your server's logical page size

actual entry length

unichar

Unicode character

Determined by your server's logical page size

n*@@unicharsize (@@unicharsize equals 2)

univarchar

Unicode character varying

Determined by your server's logical page size

actual number of characters *@@unicharsize

nchar(n)

national char[acter]

Determined by your server's logical page size

n * @@ncharsize

nvarchar(n)

nchar varying, national char[acter] varying

Determined by your server's logical page size

n

Binary datatypes

binary(n)

Determined by your server's logical page size

n

varbinary(n)

Determined by your server's logical page size

actual entry length

Bit datatype

bit

0 or 1

1 (1 byte holds up to 8 bit columns)

Text and image datatypes

text

231 -1 (2,147,483,647) bytes or fewer

0 until initialized, then a multiple of the logical page size

image

231 -1 (2,147,483,647) bytes or fewer

0 until initialized, then a multiple of the logical page size