From
http://dev.mysql.com/doc/refman/4.1/en/storage-requirements.html
DECIMAL(M,D)
It is stated that the size is
* M+2 bytes, if D > 0
* M+1 bytes, if D = 0
* D+2, if M < D
Is the last one correct? of is it D+3?
Example:
mysql> create table test (d decimal(0,2));
Query OK, 0 rows affected (0.05 sec)
mysql> show create table test;
+-------+----------------------------------------
-----------------------+
| Table | Create Table
|
+-------+----------------------------------------
-----------------------+
| test | CREATE TABLE `test` (
`d` decimal(3,2) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+----------------------------------------
-----------------------+
1 row in set (0.01 sec)
M=0 and D=2, but M is converted to 3 after the table is created,
So, with M=0, D=2, the size should be 4 according to the doc.
But, with M=3, D=2, the size should be 5 according to the doc.
Seems to be some inconsistency, is it supposed to be D+3, if M < D ?