![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, When defining numeric columns, for the last 10 years in Oracle I have NEVER specified the size for a number unless I am specifically required to do so (I think I've had a requirement to do it twice, but I can't find the example now). I have always supposed that the default size and range (and therefore the usual internal storage method) is probably going to be the 'best' choice. 'Best' is defined as least likely to cause software problems later on. Even though I know a NUMBER(4) for a year, or a NUMBER(3) for a person's age actually takes less bytes of storage than NUMBER, I learned early on in my career (Fortran/Mainframe) that playing funny games with non-standard data widths CAN cause problems and we don't need to save every last byte. A BA at my company has just mandated that all numbers in all tables must be sized at 10 digits, not just key fields. For example STAFF_ID NUMBER(10) or COUNTRY_CD NUMBER(10). The reason I have been given is they think the Oracle optimizer will trip up if numbers sizes do not match. Can anybody provide me with some insight on this? Should I have been sizing my number columns and not just take the default? Why? PS. I'm currently on a Solaris 64-bit system! Thanks! |
#3
| |||
| |||
|
|
COUNTRY_CD NUMBER(10) |
#4
| |||
| |||
|
|
Even though I know a NUMBER(4) for a year, or a NUMBER(3) for a person's age actually takes less bytes of storage than NUMBER, |
#5
| |||
| |||
|
|
VTR250 wrote: Even though I know a NUMBER(4) for a year, or a NUMBER(3) for a person's age actually takes less bytes of storage than NUMBER, That's actually incorrect. Oracle stores numbers in variable length format. Specified size is only a column constraint (which may or may not be a good choice). http://www.jlcomp.demon.co.uk/faq/num_size.html -- astaroth |
#6
| |||
| |||
|
|
100 takes up less space than 9999 -- so it is correct: you really do save 1 byte. If I'm reading your post wrongly, what specifically is incorrect in the original statement? This is a digression, however, because we're all in agreement that you don't need to save the byte, but the size limit is a good idea because it helps stop junk data getting in. |
|
Even though I know a NUMBER(4) for a year, or a NUMBER(3) for a person's age actually takes less bytes of storage than NUMBER, |
#7
| |||
| |||
|
|
VTR250 wrote: 100 takes up less space than 9999 *-- *so it is correct: you reallydo save 1 byte. *If I'm reading your post wrongly, what specifically is incorrect in the original statement? * This is a digression, however, because we're all in agreement that you don't need to save the byte, but the size limit is a good idea because it helps stop junk data getting in. Two things: 100 takes up less space than 9999 - that's right, because 100 has less significant digits. And what I did disagree with: Even though I know a NUMBER(4) for a year, or a NUMBER(3) for a person's age actually takes less bytes of storage than NUMBER, A NUMBER(4) for a year will take exactly the same amount of bytes of storage than NUMBER! Precision and scale are only constraints that prevent some values from being stored, but do not affect how much space you need to store it. 9999 takes 3 bytes whether stored in NUMBER, NUMBER(4), NUMBER(10) or NUMBER(12,2) - but Oracle will just reject this value for NUMBER(3) column. -- astaroth |
![]() |
| Thread Tools | |
| Display Modes | |
| |