Can you use a "-" in an INTEGER column in MySQL?

Perseus

Registered
I am making a column with phone numbers and was wondering if I can use dashes. I looked for info, but I needed to register for a site just to get the answer and I aint doing that.
 
Hmmm... why would you store a phone number as an integer? Why not use a text or generic field?

I would assume the only valid use of the "-" character in an integer field is to specify a negative integer.
 
You cannot do that, so either use a varchar/char field or split it up your self. Phone numbers aren't really "numbers" in the sense that you don't compute things with them, its more a string of numbers, I would use either a char or a varchar field so you don't have to create a string from a number and split it up to add the - and stuff.
 
And figure out when you're specifying the length of this column whether you're going to embrace international numbers. Allow more than 10 chars if you're going to store numbers outside North America. varchar(24) should cover all possible situations.
 
Back
Top