Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Decimal problem

 
Cheryl Gray
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic