FLOAT[(width, decimals UNSIGNED [ZEROFILL] or
FLOAT[(precision)] [UNSIGNED]
[ZEROFILL]
Stores floating-point numbers. It has two optional syntaxes: the first
allows an optional number of decimalsand an optional display
width, and the second allows an optional
precisionthat controls the accuracy of the approximation measured in bits. Without parameters,
the type stores small, four-byte, single-precision floating-point values usually, you use it without providing any parameters. When
precisionis between 0 and 24, the default behavior occurs. When
precisionis between 25 and 53, the type behaves as for DOUBLE. The
widthhas no effect on what is stored, only on what is displayed. The
UNSIGNED
and
ZEROFILL
options
behave as for INT
DOUBLE[(
width,
decimals)] UNSIGNED [ZEROFILL]
Stores floating-point numbers. It has one optional syntax it allows an optional number of
decimalsand an optional display
width. Without parameters,
the type stores normal, eight-byte, double-precision floating point values usually, you use it without providing any parameters. The
widthhas no effect on what is stored,
only on what is displayed. The
UNSIGNED
and
ZEROFILL
options behave as for
INT
The
DOUBLE
type
has two identical synonyms REAL
and DOUBLE PRECISION. The
REAL
alternative can be made to behave as
FLOAT
using a nondefault parameter to the MySQL server, but this is not discussed here.
Other date and time typesWe
discussed the DATE, TIME, and TIMESTAMP types in Common column types There are two more date and time types
YEAR
for storing only year values, and
DATETIME
for storing date and time combinations without the automatic-update feature of
TIMESTAMP
. These work as follows:
YEAR[(
digits)]
Stores
a two- or four-digit year, depending on whether or is passed as the optional digits parameter. Without the parameter, four digits is the default. The two- digit version stores values from 70 to 69, representing 1970 to 2069; again, we caution against using two-digit dates. The four-digit version stores values in the range 1901 to 2155, as well as the
zero year, 0000. Illegal values are converted to the zero date. You can input year values as either strings (such as '2005'
) or integers
(such as
2005
). The
YEAR
type requires one byte of storage space.
DATETIME
Stores and displays a date
and time pair in the format YYYY-MM-DD HH:MM:SSfor the range
1000-01-01 to
9999-12-31 23:59:59
. As for TIMESTAMP, the value stored always matches the template
YYYY-MM-DD HH:MM:SS, but the value can be input in the
same formats listed for the TIMESTAMP
description. If you assign only a date to a
DATETIME
column, the zero time is assumed. If you assign only a time to a
DATETIME
column, the zero date is assumed. This type does not have the automatic update features of
TIMESTAMP
Share with your friends: