Types Of Numeric Values; Decimal Data Type Changes - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

• Control over handling of invalid values: Overflow and division by zero are detectable and can be
treated as errors. For example, you can treat a value that is too large for a column as an error rather
than having the value truncated to lie within the range of the column's data type. Similarly, you can
treat division by zero as an error rather than as an operation that produces a result of NULL. The
choice of which approach to take is determined by the setting of the server SQL mode.
The following discussion covers several aspects of how precision math works, including possible
incompatibilities with older applications. At the end, some examples are given that demonstrate how
MySQL 5.0 handles numeric operations precisely. For information about controlling the SQL mode, see
Section 5.1.7, "Server SQL

12.17.1. Types of Numeric Values

The scope of precision math for exact-value operations includes the exact-value data types
and integer types) and exact-value numeric literals. Approximate-value data types and numeric literals
are handled as floating-point numbers.
Exact-value numeric literals have an integer part or fractional part, or both. They may be signed.
Examples: 1, .2, 3.4, -5, -6.78, +9.10.
Approximate-value numeric literals are represented in scientific notation with a mantissa and exponent.
Either or both parts may be signed. Examples: 1.2E3, 1.2E-3, -1.2E3, -1.2E-3.
Two numbers that look similar may be treated differently. For example,
point) number, whereas
The
DECIMAL
has several synonyms: NUMERIC, DEC, FIXED. The integer types also are exact-value types.
The
FLOAT
MySQL, types that are synonymous with
12.17.2.
DECIMAL
This section discusses the characteristics of the
5.0.3, with particular regard to the following topics:
• Maximum number of digits
• Storage format
• Storage requirements
• The nonstandard MySQL extension to the upper range of
Some of these characteristics result in possible incompatibilities for applications that are written for
older versions of MySQL. These incompatibilities are noted throughout this section.
The declaration syntax for a
for the arguments has changed somewhat:
is the maximum number of digits (the precision). It has a range of 1 to 65. This introduces a
M
possible incompatibility for older applications, because previous versions of MySQL permit a range
of 1 to 254. (The precision of 65 digits actually applies as of MySQL 5.0.6. From 5.0.3 to 5.0.5, the
precision is 64 digits.)
is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and
D
must be no larger than M.
The maximum value of 65 for
digits. This limit of 65 digits of precision also applies to exact-value numeric literals, so the maximum
Types of Numeric Values
Modes".
is an approximate-value (floating-point) number.
2.34E0
data type is a fixed-point type and calculations are exact. In MySQL, the
and
data types are floating-point types and calculations are approximate. In
DOUBLE
Data Type Changes
DECIMAL
means that calculations on
M
or
are
FLOAT
DOUBLE
data type (and its synonyms) as of MySQL
DECIMAL
DECIMAL
column remains DECIMAL(M,D), although the range of values
DECIMAL
1002
is an exact-value (fixed-
2.34
and REAL.
DOUBLE PRECISION
columns
values are accurate up to 65
(DECIMAL
type
DECIMAL

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 5.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Mysql 5.0

Table of Contents