June 2010
Intermediate to advanced
328 pages
7h 51m
English
Instead of FLOAT or its siblings, use the NUMERIC or DECIMAL SQL data types for fixed-precision fractional numbers.
| Rounding-Errors/soln/numeric-columns.sql | |
| | ALTER TABLE Bugs ADD COLUMN hours NUMERIC(9,2); |
| | ALTER TABLE Accounts ADD COLUMN hourly_rate NUMERIC(9,2); |
These data types store numeric values exactly, up to the precision you specify in the column definition. Specify precision as an argument to the data type, similar to the syntax you would use for the length of a VARCHAR data type. The precision is the total number of decimal digits you can use in a value in this column. A precision of 9 means that you can store a value like 123456789, but you may not be able to store 1234567890.[11]
You may also ...
Read now
Unlock full access