float, real, and double precision  Integer types and their unsigned counterparts

Chapter 7: Adding, Changing, and Deleting Data

decimal and numeric

The exact numeric types—dec, decimal, and numeric—begin with an optional positive or negative sign and can include a decimal point. The value of exact numeric data depends on the column’s decimal precision and scale, which you specify using this syntax:

datatype [(precision  [, scale ])]

Adaptive Server treats each combination of precision and scale as a distinct datatype. For example, numeric (10,0) and numeric (5,0) are two separate datatypes. The precision and scale determine the range of values that can be stored in a decimal or numeric column:

If a value exceeds the column’s precision or scale, Adaptive Server flags the entry as an error. Here are some examples of valid dec and numeric data:

Table 7-2: Valid precision and scale for numeric data

Data entered

Datatype

Precision

Scale

Value

12.345

numeric(5,3)

5

3

12.345

-1234.567

dec(8,4)

8

4

-1234.567

The following entries result in errors because they exceed the column’s precision or scale:

Table 7-3: Invalid precision and scale for numeric data

Data entered

Datatype

Precision

Scale

1234.567

numeric(3,3)

3

3

1234.567

decimal(6)

6

1





Copyright © 2005. Sybase Inc. All rights reserved. Integer types and their unsigned counterparts

View this book as PDF