473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

size of numeric data

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

Jun 27 '08 #1
8 9195
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
Cheers,

Dave.

Jun 27 '08 #2
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
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
That is true with some databases, but not with DB2 unless you are
specifically using compression.
Jun 27 '08 #3
>>On 5/13/2008 at 12:25 PM, in message
<la******************************@posted.plusnet >, Dave
Hughes<da**@waveform.plus.comwrote:
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
Jun 27 '08 #4
>>On 5/13/2008 at 5:24 PM, in message
<7q*********************@bignews6.bellsouth.net> , Mark
A<no****@nowhere.comwrote:
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
>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?

That is true with some databases, but not with DB2 unless you are
specifically using compression.
Do you by chance know if Oracle is one of the "some databases"? The DBA is
an Oracle guy who we also have working on DB2 now.

Thanks,
Frank

Jun 27 '08 #5
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
Do you by chance know if Oracle is one of the "some databases"? The DBA
is
an Oracle guy who we also have working on DB2 now.

Thanks,
Frank
I believe that Oracle is one of the databases that automatically compresses
some data types.
Jun 27 '08 #6
Frank Swarbrick wrote:
>>>On 5/13/2008 at 5:24 PM, in message
<7q*********************@bignews6.bellsouth.net> , Mark
A<no****@nowhere.comwrote:
>"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
>>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?
That is true with some databases, but not with DB2 unless you are
specifically using compression.

Do you by chance know if Oracle is one of the "some databases"? The DBA is
an Oracle guy who we also have working on DB2 now.
NUMBER is stored similar to a "VARCHAR". Call it VARDECIMAL if you wish.
That is the storage depends on the number of digits, where trailing 0's
are removed.

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #7
>>On 5/13/2008 at 7:48 PM, in message
<68*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
Frank Swarbrick wrote:
>>>>On 5/13/2008 at 5:24 PM, in message
<7q*********************@bignews6.bellsouth.net >, Mark
A<no****@nowhere.comwrote:
>>"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
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?
That is true with some databases, but not with DB2 unless you are
specifically using compression.

Do you by chance know if Oracle is one of the "some databases"? The DBA
is
>an Oracle guy who we also have working on DB2 now.
NUMBER is stored similar to a "VARCHAR". Call it VARDECIMAL if you wish.
Really! Interesting.
That is the storage depends on the number of digits, where trailing 0's
are removed.
Leading zeroes as well?

Any idea where I can find more information on this? I want to know all I
can before bring it do my DBA.

Thanks!
Frank
Jun 27 '08 #8
>>On 5/14/2008 at 4:54 PM, in message
<48******************@efirstbank.com>,
Frank Swarbrick<Fr*************@efirstbank.comwrote:
>>>On 5/13/2008 at 7:48 PM, in message
<68*************@mid.individual.net>,
Serge Rielau<sr*****@ca.ibm.comwrote:
>NUMBER is stored similar to a "VARCHAR". Call it VARDECIMAL if you wish.
>

Really! Interesting.
>That is the storage depends on the number of digits, where trailing 0's
are removed.

Leading zeroes as well?

Any idea where I can find more information on this? I want to know all
I
can before bring it do my DBA.
Found what I was looking for:

http://download.oracle.com/docs/cd/B.../datatype.htm#
i16209

"Internal Numeric Format
Oracle Database stores numeric data in variable-length format. Each value is
stored in scientific notation, with 1 byte used to store the exponent and up
to 20 bytes to store the mantissa. The resulting value is limited to 38
digits of precision. Oracle Database does not store leading and trailing
zeros. For example, the number 412 is stored in a format similar to 4.12 x
102, with 1 byte used to store the exponent(2) and 2 bytes used to store the
three significant digits of the mantissa(4,1,2). Negative numbers include
the sign in their length.

Taking this into account, the column size in bytes for a particular numeric
data value NUMBER(p), where p is the precision of a given value, can be
calculated using the following formula:

ROUND((length(p)+s)/2))+1
where s equals zero if the number is positive, and s equals 1 if the number
is negative.

Zero and positive and negative infinity (only generated on import from
Oracle Database, Version 5) are stored using unique representations. Zero
and negative infinity each require 1 byte; positive infinity requires 2
bytes."

The DB2 way is more familiar to me, being a Cobol programmer. Cobol stores
numeric data in a very similar fashion.

I am sure there are both good and bad points to both the DB2 way and the
Oracle way. The one thing that seems nice about the Oracle way is you don't
really have to worry ahead of time about the maximum value that would ever
need to be stored in a particular column. As long as it's not more that 38
digits of precision you're good to go!

We had a problem just the other day where we had a Cobol field defined as
PIC S9(9)V99 (which can hold a maximum value of 999,999,999.99) and we ended
up generating (or trying to generate, I should say) a transaction for over a
billion dollars. Well the most significant digit was truncated, so we were
'out of balance' by $1 billion. Don't worry! No customer was affected!!
<g Still, not good. Obviously whoever designed the data store at the time
couldn't imagine a single transaction of this type that would ever be this
large.

Frank

Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brian | last post by:
Does anyone know of any articles that discuss the best practice for choosing a numeric data type. I remember seeing a good article in the past, but can't remember where. I am interested in articles...
1
by: mmuriegas | last post by:
Numeric data is imported as integer's. Loss of the fractions throws the calculations off. I am following the trail of a previous programmer and found that he was impoting a file "import delimited",...
1
by: Mike P | last post by:
I am using a stored procedure to get a value from a table, but the parameter I need to pass is a numeric data type in the table. The SQL Parameter object in .NET seems to support most of the SQL...
2
by: sp | last post by:
Hello Everybody, How can I restrict the user entering non-numeric data in textbox control on server side using asp.net. Any Code sample or suggestions are appreciated. Thanks in advance sp
2
by: John A Grandy | last post by:
how do VB.NET numeric data-types match-up to SQL-Server numeric data-types ? is it safe to use declare VB.NET variables of type Integer to contain SQL Server columns of type Integer ?
3
by: Tim Groulx | last post by:
Hello, I need to be able to select only the numeric data from a string that is in the form of iFuturePriceID=N'4194582' I have the following code working to remove all the non-numeric text...
3
by: loisk | last post by:
Hi, Can anyone tell me.... What is the equivalent of "" (blank of string data type) with numeric data type? The default of my numeric data type control is 0, and I'd like trigger the event...
1
by: Erik Nodland | last post by:
Hi Everyone, Just after some ideas and suggestions on how to do this. I have a large amount of numeric data which I would like to group given a distance as a parameter. IE. If my dataset was...
4
code green
by: code green | last post by:
I have a text field called notes in which users have typed almost anything they like. I need to find numeric data randomly inserted in there. So for example there may be a telephone number and an...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.