Re: size of numeric data >>> On 5/13/2008 at 12:25 PM, in message
<laSdnXAOn6mJQLTVnZ2dnUVZ8gidnZ2d@posted.plusnet >, Dave
Hughes<dave@waveform.plus.com> wrote:
> Frank Swarbrick wrote:
>
>> My DBA says that a column defined, for instance, as DECIMAL(11,2) and
>> containing a value of 1.00 takes up no more space on the database
>> disk than a column defined as DECIMAL(7,2) and containing a value of
>> 1.00.
>>
>> I am honestly having a hard time believing this, but I don't know
>> where I can find the answer.
>> Help?
>>
>> Thanks,
>> Frank
>
> Your DBA is indeed mistaken (assuming he's referring to DB2 :-). From
> the CREATE TABLE reference in the DB2 9.5 InfoCenter [1] (search for
> the "Storage Byte Counts" heading):
>
> "Storage Byte Counts: The following table contains the storage byte
> counts of columns by data type for data values. The byte counts depend
> on whether or not VALUE COMPRESSION is active. When VALUE COMPRESSION
> is not active, the byte counts also depend on whether or not the column
> is nullable. The values in the table represent the amount of storage
> (in bytes) that is used to store the value.
>
> ...
>
> DECIMAL (when VALUE COMPRESSION is not active and the column is not
> nullable): The integral part of (p/2)+1, where p is the precision"
>
> So a DECIMAL(11,2) NOT NULL column without VALUE COMPRESSION requires 6
> bytes, while a DECIMAL(7,2) column with the same attributes requires 4
> bytes per row, regardless of the value stored within the row.
>
> [1]http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db
> 2.luw.sql.ref.doc/doc/r0000927.html
Thanks for the link. Looks like exactly what I need.
Frank |