SQL data types

Puiu

Well-known member
Joined
Oct 6, 2004
Messages
90
I want to store a 13 digits number in a table in a database and i was curios what would be the best data type to do this?
Varchar or Bigint ?

I dont need to calculate anything with these numbers, just to store them using the lowest disk space
 
I dont know whether it applies to general programming, but when I was working with access databases back at 6th form (5 years ago now) we were told that if a number will never be used for calculation you should store it as a string.
 
Puiu said:
I want to store a 13 digits number in a table in a database and i was curios what would be the best data type to do this?
Varchar or Bigint ?

I dont need to calculate anything with these numbers, just to store them using the lowest disk space
diskspace is cheap compared to a hard to find bug.
store them in char(13) - left pad with zeros.

nothing worse that people storing SSNs in int fields.
 
For me, if I know its a number that Im storing, Id rather use a bigint than varchar. Im thinking ahead to when this is read out - if its varchar, theres a chance someone will put the letter "a" out there. I hate writing conversion programs for older systems where everything was a varchar, even dates, and you get those weird anomalies that wont convert right.

If this is a number that "looks like" a number but isnt (like an SSN), Id definitely store as varchar.

-ner
 
Back
Top