MySQL Forums
Forum List  »  Newbie

Re: size of Decimal(18,4)
Posted by: Rick James
Date: January 02, 2011 05:14PM

Which version of MySQL? The underlying implementation changed a few years ago.

Currently, I would say 9 bytes, empirically derived:

mysql> create table f401075 (
a DECIMAL(18,4) NOT NULL,
b DECIMAL(18,4) NOT NULL,
c DECIMAL(18,4) NOT NULL
) ENGINE=MyISAM;
mysql> insert into f401075 values (1,2,3);

mysql> show table status like 'f401075'\G
*************************** 1. row ***************************
Name: f401075
Engine: MyISAM
Version: 10
Row_format: Fixed
Rows: 1
Avg_row_length: 28
...

1 byte overhead + 3 fields * 9 bytes = 28 bytes.

Possibly the 9 bytes is
3 bytes for 5 digits +
4 bytes for 9 digits +
2 bytes for 4 digits (after decimal point).

Options: ReplyQuote


Subject
Written By
Posted
January 01, 2011 11:16AM
Re: size of Decimal(18,4)
January 02, 2011 05:14PM
January 03, 2011 02:45AM
January 03, 2011 09:22AM
January 03, 2011 10:42AM


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.