About Datatype in DB2 Database
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 integer value? If yes then Is it efficient then Integer Datatype? In My Database all the integer values are defined as DECIMAL datatype.
How is it Useful here to use Decimal datatype?
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.
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: -1031+1 to 1031-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.
精彩评论