tags:

views:

32

answers:

2

Hello..I have some doubts on using DECIMAL datatype in DB2 database.there is one datatype DECIMAL in DB2...can we use this datatype for representing a interger value???..If yes then Is it efficient then Interger Datatype??.....In My Database all the integer values are defined as DECIMAL datatype....How is it Useful here to use Decimal datatype???.....Please solve this problem..

+1  A: 

I can't tell you how it is useful to use decimal in your database because I don't know what it is trying to achieve, but if you need to store integers why not just use the integer datatype? there is no advantage to using decimal over integer if you just need integers - in fact its probably a detriment.

Darko Z
But Those Database is created by other department..and they have used Decimal datatype...I'm also confused that Why they hv used That datatype..u hv any solution then tell me...plz.
Mayur_Patel
As I said, noone other than the people who created the database can tell you WHY they did what they did, we're not mindreaders.
Darko Z
A: 

A DECIMAL datatype can include a decimal point, giving up to 31 digits of precision. An INTEGER datatype cannot, since it's an integer.

You certainly can use the DECIMAL datatype to represent an integer, although if you're storing an integer you should probably use the INTEGER datatype to prevent confusion.

My best guess as to why your database uses DECIMAL to represent an integer is because DECIMAL affords a larger range: -10*31+1 to 10*31-1. INTEGER only goes from -2,147,483,648 to +2,147,483,647, and BIGINT goes from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.

CanSpice
Oh.. Thanks for your answer...I liked it.
Mayur_Patel
Then feel free to either vote it ip (hit the arrow above the "0" to the left of it) or accept it as your preferred answer. Thanks!
CanSpice
So its just they took decimal datatype for jst increasing a range...
Mayur_Patel