Inserting BigDecimal =>Varchar2 column VS BigDecimal=>Number column
I was doing some tests, where I inserted some records of java bigDecimal to a varchar2 column in Oracle. What I wanted to do was insert java bigDecimal to number column in Oracle.
I am wondering how the 2 work differently and what interim conversion steps does Oracle take in the scenarios.
- BigDecimal =>Varchar2 column BigDecimal=>Number column
Can I still use 开发者_开发知识库the findings from my previous tests. I am mostly looking at latency, throughput etc.
Remember the golden rule: You should never ever under no circumstances store numbers in varchar columns.
Storing numbers in character columns will give you a lot of trouble in the long run.
Always store numbers as numbers.
To store the numbers, use a PreparedStatement and use the setBigDecimal() method to send the number to the database. This will take care of any conversion and will guarantee that the correct value is stored in the database and you don't have to worry e.g. about different decimal separators in different locales when sending a number as a string to the database.
I did not find any measurable performace difference. This was just a test of a prototype so I can use the results.
精彩评论