My application interacts with an Oracle database in which a table has 1 million records. The problem is:
In that table we have a column for numeric integer types.We want to store float values (2 digits).We could do that by multiplying with 100 (from the application) and store them in that column or modify the column data type.The question is :
What takes less time?
The alter table modify column or the query (update table set column = 100*val).
A
NUMBERin Oracle has no intrinsic “format”, i.e. its internal representation will not depend upon its precision or scale. TheNUMBER123456 for example will be represented internally the same way if it is declared as aNUMBER(9,2)orINTEGER:The only difference in a column between an
INTEGER(7)and aNUMBER(9,2)is that theINTEGER(7)has a stronger check constraint. Both columns will represent the data internally in the exact same way.This is why you can increase the precision of your column of a non-empty column without problem, and the
ALTER TABLEwill only modify the metadata (dictionary tables) and thus should be instant with very little redo.