Is there any benefit to specifying the precision on the PK? Is 7,0 sufficient, given that there will probably never be more than a few thousand records?
Any dangers to not specifying the precision?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NUMBER(7, 0)just constrains the domain of values.Their internal represenations do not differ:
In
Oracle, theNUMBERs are stored as centesimal digits of the numeric value normalized to0.01 <= N < 1and prepended with the exponent.In the example above:
196is the192-based exponent (4).10is decimal9100‘s are decimal99‘sThe whole number reads in decimal as
00.09 99 99 99 * (100 ^ 4) = 9,999,999The more digits are required to satisfy the precision requested, the more of them will be stored of course.
When you insert a precise value into a less precise column, it just gets rounded to column’s precision and is stored rounded.
Therefore, it is safe performance-wise to declare you column
NUMBER(38), since it implies no overhead overNUMBER(7, 0)(for the numbers that fit both types).However, if your
PRIMARY KEYs are integer by nature, you better specify precision as0to make sure no fractional value ever gets to your table.Update:
@Mac also pointed that the clients may rely on the column datatype to figure out the values domain.
If your application expects an
INT32, you should make your number aNUMBER(9)or below (or whatever type your client considers to be convertable toInt32).