A NUMBER
column will never store the decimal value if it doesn't need to.
You can, however, control how the data is displayed to the user when it is converted to a string by using an explicit TO_CHAR
rather than relying on implicit data type conversion. If you use the format mask 9.0
in your TO_CHAR
call, for example, the string that is generated will always have 1 decimal digit.
SQL> select to_char( 4, '9.0' )
2 from dual;
TO_C
----
4.0
SQL> ed
Wrote file afiedt.buf
1 select to_char( 4.1, '9.0' )
2* from dual
SQL> /
TO_C
----
4.1
That being said, it seems unlikely that you would really want to store software version information in a NUMBER
column rather than a VARCHAR2
. You, presumably, aren't doing any mathematical operations on the data so most of the benefit of having a NUMBER
is off the table. And software versions are not inherently numeric. You often find yourself wanting more than two components (i.e. Oracle 11.2.0.1). And software versions tend to have highly non-numeric things done to them. If the version that follows 4.9 is 4.10, that's very different than the version 4.1 that followed 4.0. If you're using a NUMBER
, though, you lose the ability to differentiate between those versions.