Using numeric(p) vs integer
Posted in 1999
Topics: Data Types & Schema Design
I'm an Informix newbie. Ant help would be appreciated. I'm running 7.22 on NT 4.0. I have a field in a table which holds a value up to 10 digits. This is defined as "numeric(10)". Is there any advantage to utilizing this data type versus using a data type of "integer" instead? Also Informix documentation lists storage space for decimal data types with both a precision and a scale. That is the documentation does not distinguish between floating point and fixed point for storage allocation. How would this differ e.g. numeric (10), nemeric (10,3) ? Thanks JV -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
jvnet@excite.com wrote: > > I'm an Informix newbie. Ant help would be appreciated. I'm running 7.22 on > NT 4.0. I have a field in a table which holds a value up to 10 digits. This > is defined as "numeric(10)". Is there any advantage to utilizing this data > type versus using a data type of "integer" instead? Also Informix Well, integer holds 9+ digits decimal(10) (or numeric(10)) holds 10 digits floating point. (BTW if you need a 10 digit integer you can use decimal(10,0)). Decimal(10) uses 6 bytes of storage compared to 4 for integer. Calculations are slightly, though noticeably, faster for integer but formatting to string is slightly faster for decimal(10). > documentation lists storage space for decimal data types with both a > precision and a scale. That is the documentation does not distinguish > between floating point and fixed point for storage allocation. How would this > differ e.g. numeric (10), nemeric (10,3) ? Thanks JV Storage required of decimal(10) and decimal(10,3) or decimal(0) is the same though decimal types declared with an explicit scale are slightly more efficient to calculate with, in my experience, than decimals declared floating. Art S. Kagel
In article <7etib0$8j2$1@nnrp1.dejanews.com>, <jvnet@excite.com> wrote: >I'm an Informix newbie. Ant help would be appreciated. I'm running 7.22 on >NT 4.0. I have a field in a table which holds a value up to 10 digits. This >is defined as "numeric(10)". Is there any advantage to utilizing this data >type versus using a data type of "integer" instead? From the Informix Guide to SQL: Reference, Version 7.2, page 3-16: -- The INTEGER data type stores whole numbers that range from -2,147,483,647 to 2,147,483,647. The maximum negative number, -2,147,483,648, is a reserved value and cannot be used. The INTEGER data type is stored as a signed binary integer and is typically used to store counts, quantities, and so on. -- INTEGER can be interpreted as 32-bit unsigned data, with one caveat: there's a hole at 2,147,483,648. That number is not representable with an INTEGER type, since this value is reserved to represent a NULL. NUMERIC(10) gives you the range -9,999,999,999 to 9,999,999,999 without any such holes. Jim -- W. Jim Jordan, Nortel Networks, Stop 313 Qualicum, PO Box 3511 Stn C, Ottawa, ON K1Y 4H7 Canada wjjordan@nortelnetworks.com Opinions expressed are not necessarily those of Nortel Networks. Inbound spam filtering is in place; don't send what I won't see.