Need to store ZIP codes in a database? Don't use an integer data type; use a 10-character string instead (e.g. VARCHAR(10)).

Reason 1: ZIP codes can contain non-numeric characters

Yes, the initial 5-digit ZIP code from 1963 uses a numeric-only alphabet. But the ZIP+4 introduced 20 years later has the format XXXXX-XXXX. That's 9 digits with a hyphen in the middle. And hyphens are not numeric!

Of course, I recognize that the hyphen can easily be removed before storing ZIP+4 to a database, but while that technically works, it feels somewhat hacky. What happens when business expands to Canada or the UK, where the postal codes are made up of both letters and numbers? A schema migration, that's what!

Reason 2: ZIP codes can start with zero

Let's pretend that you don't need to support the ZIP+4 or international formats. Well, ZIP codes are still not integers! ZIP codes for New England states all start with a "0." If your database stores its ZIP codes as integers, then those leading zeroes are stripped. That means a Boston ZIP code (02115) would incorrectly show up as a four-digit number (2115) instead.

Again, there are workarounds, like the use of ZEROFILL to automatically left-pad those 4-digit edge cases. But this is somewhat hacky; New England shouldn't really be considered an edge case. Plus, many languages interpret numbers that start with zero as octal (thanks for the reminder, Simon!).

Reason 3: ZIP codes act like strings

ZIP codes aren't used in numerical operations. It doesn't make sense to add two ZIP codes together or to divide a ZIP code by 3. That's because 5-digit ZIP codes aren't numbers; they just happen to be restricted to a numbers-only alphabet.

On the other hand, string operations do make sense with ZIP codes. The first digit of a ZIP code maps to a fixed set of US states, the next two to a region or city, and the last two to an area within a city. Sure, integer modulo operations can parse these digits for you, but it's simpler and more semantically correct to use a string index method instead.

And the + operator? Probably more useful if the default string implementation, i.e. concatenation, and not the integer implementation, i.e. addition, is available to append a ZIP code to an address without casting or throwing an error about incompatible types.

The first digit of a ZIP code maps to a large section of the US.
https://zipcodedownload.com/what-is-the-5-digit-zip-code

And there you have it. Three good reasons not to use integer ZIP codes. I hope it's enough.