Databases Reference
In-Depth Information
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 decimals and an optional display width , and the second allows
an optional precision that 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
precision is between 0 and 24, the default behavior occurs. When precision is
between 25 and 53, the type behaves as for DOUBLE . The width has 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 decimals and 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 width has 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 types
We 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 2 or 4 is passed as the op-
tional 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:SS for the
range 1000-01-01 00:00:00 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 00:00:00 is assumed. If you assign only a
time to a DATETIME column, the zero date 0000-00-00 is assumed. This type does
not have the automatic update features of TIMESTAMP .
 
Search WWH ::




Custom Search