MySQL Forums
Forum List  »  Docs

Size of Decimal, version 4.1
Posted by: KimSeong Loh
Date: February 13, 2006 08:32PM

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 ?

Options: ReplyQuote


Subject
Views
Written By
Posted
Size of Decimal, version 4.1
6875
February 13, 2006 08:32PM
2781
February 17, 2006 04:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.