Friday, February 24, 2012

Can someone explain the precision of an integer in a sql db pls

Hi I am in the process of creating a new db in sql. In my users table I wish to set the UserIds as Integer datatype. It defualts on precision 4. Does this mean that when the column auto increments as its my primary key with a seed of one, my highest number allowed in the table would be row 9999. ?

Also if you where to store a phone number in your db, what column type would you give it. I have used varChar but its all numbers i want to store. Would this suffice.

ThanksHi,

That's four bytes, not four number places. So the range is from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647). That's a lot of users... :-D

I usually store phone numbers as varchars, whether I include formatting symbols--(, ), -, whatever--or not. That way you don't have to worry about trailing zeroes (or leading ones if you also are using international phone numbers), and formatting for the user interface is way easier. In fact, if you are storing international phone numbers, you probably want to include the symbols as well.

Don

No comments:

Post a Comment