aspose file tools*
The moose likes JDBC and the fly likes Decimal problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Decimal problem" Watch "Decimal problem" New topic
Author

Decimal problem

Cheryl Gray
Ranch Hand

Joined: Nov 17, 2000
Posts: 44
I was taking an online class and I saw this,
CREATE TABLE STAFF(STAFFNUM DECIMAL(6,0));

Could we also put this as STAFFNUM INT ? Why are users allowed to specify 0 decimal places?


Anything is possible to those who believe.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Maybe the table creator was trying to specify that the id number cannot be more than six digits?

I suspect this could be a char(6) or varchar(6) column rather than numeric in the first place. Unless it makes sense to do arithmetic or numerical comparisons with ids, they aren't really numbers. They are identifiers that happen to consist of digits.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Jeanne Boyarsky:
Maybe the table creator was trying to specify that the id number cannot be more than six digits?

I suspect this could be a char(6) or varchar(6) column rather than numeric in the first place. Unless it makes sense to do arithmetic or numerical comparisons with ids, they aren't really numbers. They are identifiers that happen to consist of digits.


STAFFNUM is likely similar to my employee number... which happens to be 6 digits as well.

From a data modeling standpoint... it isn't really a number and should be stored as character data.
[ October 19, 2007: Message edited by: Paul Campbell ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Decimal problem