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.
- zip codes have extensions, meaning can
12345-6789. cannot store dash in numeric datatype. - there many zip codes start zero, if store int going lose leading zero.
- 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
Post a Comment