Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to store postal codes in a database. How big should the column be?

I expect the column to be a VARCHAR2, in my Oracle Database.

US Zips are 9.

Canadian is 7.

I am thinking 32 characters would be reasonable upper limit

What am I missing?

[EDIT] TIL: 12 is a reasonable answer to the question Thanks to everyone who contributed.

like image 415
EvilTeach Avatar asked Nov 28 '08 04:11

EvilTeach


People also ask

What is the best data type for a postcode field in database?

The right data type for a postal code is a string. In a SQL database, this would typically be VARCHAR() or CHAR() , of the appropriate length.

What format should be used for postcode data?

You can format a cell or range of cells to display leading characters so that the postal code is preceded by enough characters to fill the cell's width. For example, you can use zeros or dashes to display a postal code as follows: 0000000 98052 or ------- 98052.

What is the maximum length of postal code?

United States ZIP codes are five numerical digits long. ZIP+4 codes, also known as add-on or plus-four codes, include four additional digits that identify a geographic segment within a ZIP code delivery area. The first digit in a ZIP code represents a defined group of U.S. states.

Should the database store a postal code as an integer?

ZIP codes should not be stored as integers. If you were going to incorrectly store a ZIP code as an integer, you'd store the value 7601 and then need to know when you display it that you need to add in the leading 0.

Which is the best database for postal codes?

If you want to integrate postal codes in database then geonames database is best to use. Even though it is tough to use and understand but it is the largest geographical database available freely to users like us. All the other such database are more or less likely have same data and structure.

What is the data type for postal address in SQL database?

OQ: What is the data type for postal address in SQL database? Address is rather entity (set of attributes) than single value. Address can be reflected with several (usually text) values for country, city name, street name and number, zip code and flat number.

How many lines of data do I need for UK postal codes?

UK have published standards: UK Government Data Standards Catalogue Minimum of 2 lines and maximum of 5 lines for the postal delivery point details, plus 1 line for country and 1 line for postcode/zip code If you want to integrate postal codes in database then geonames database is best to use.

How to store phone numbers in a database?

Choosing the right data type. (Integer or String) Choosing the format type. (International or National) Verifying the phone number. Best way to store Phone Numbers in a database. Here are the steps which you need to take before you store a phone number in a database. Take input from the user. Identify the country of the user.


2 Answers

Skimming through Wikipedia's Postal Codes page, 32 characters should be more than enough. I would say even 16 characters is good.

like image 104
strager Avatar answered Oct 03 '22 19:10

strager


As already raised by @neil-mcguigan, wikipedia has a decent page on the topic. Based on that 12 characters should do it: http://en.wikipedia.org/wiki/List_of_postal_codes

The wikipedia article lists ~254 countries, which is pretty good regarding UPU (Universal Postal Union) has 192 member countries.

like image 29
Vajk Hermecz Avatar answered Oct 03 '22 17:10

Vajk Hermecz