mysql - What is the best column type for a United States ZIP code? -


i want store zip code (within united states) in mysql database. saving space priority. better option using varchar - limited maximum length of 6 digit or using int or using medium int . zip code not used calculation. zip code used insert (once), updated (if required) , retrieved - once (but can more once) .

which better option use here varchar or int or medium in mysql ? please suggest else ?

there few problems storing zip code numeric value.

  1. zip codes have extensions, meaning can 12345-6789. cannot store dash in numeric datatype.
  2. there many zip codes start zero, if store int going lose leading zero.
  3. you not add/subtract, etc zip codes or use numeric functions them.

i store zip code varchar(5) or varchar(10).

as side note, not sure why select varchar(6), have reason selecting unusual length when standard zip codes 5 or 10 extension?


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -