Database Reference
In-Depth Information
Table 3.3
Single precision floats datatype ranges.
Declaration
Number inserted
Number stored
FLOAT(5, 2)
3.141 59
3.14
FLOAT(5, 2)
42
42.00
FLOAT(5, 2)
-23 453.543
-23 453.54
FLOAT(5, 2)
4932.32
4932.32
FLOAT(5, 2)
493 212 343.3423
493 212 352.00
FLOAT(5, 2)
49 321 234 532.3423
493 212 344 432.00
specified, the decimal places have just been set to zero, and the less significant part of the
numbers stored is not the same as the number that was entered.
The idea behind this sort of datatype is that when handling very large numbers, the
magnitude of the number is more important than the fine details of the number. For
instance if you had $10 000 026.51, in the bank, the $10 million would be of more impor-
tance to you than the $26.51!
DOUBLE
Another floating point datatype is DOUBLE. This works in exactly the same way as the
FLOAT declaration above when used with the two attributes as follows:
columnname DOUBLE (magnitude, decimals)
This time the number stored will obviously be of the double precision type, but the
attributes are the same as follows:
magnitude is the number of digits used to store the number.
decimals is the number of decimal digits to be stored.
In other SQL texts you may see references to REAL and DOUBLE PRECISION datatypes.
You can use these as well in MySQL but they are exactly the same as the DOUBLE datatype.
Character Types
The character datatypes are those used for storing characters and strings. The letters in this
sentence are all characters, and the sentence itself is a string. In fact as I am sitting here typ-
ing this, Microsoft Word is probably thinking that this whole topic is just a string of char-
acters, all be it a big one. When specifying a string, you normally surround it with
something, such as quote marks, to highlight to the MySQL server that what is inside the
quotes should be treated differently to what is outside of them. This is something that we
are used to in written text, for instance:
Gandalf spluttered, “Fly, you fools!”
Search WWH ::




Custom Search