Why would you declare a field size larger than the actual data that you expect to store in it?
If the original version of your application will support the addresses of the USA and Canada (which I deduced from the fact that you specified these sizes in your question), I would declare this field as VARCHAR2 (9) (or VARCHAR2 (10) if you are going to store hyphen in ZIP + 4 fields). Even looking at messages made by other people in the postal codes by country, VARCHAR2 (9) or VARCHAR2 (10) will be sufficient for most, if not all other countries.
Down the line, you can always add an ALTER column to increase the length if necessary. But, as a rule, itβs difficult to prevent someone, somewhere from making a decision about getting βcreativeβ and 50 other characters in the VARCHAR2 field (50) for one reason or another (i.e., because they want a different line on transport label). You should also deal with borderline cases (will there be every application that displays a 50 character zip descriptor?). And with the fact that when clients retrieve data from a database, they usually allocate memory based on the maximum size of the data to be retrieved, rather than the actual length of a given row. This is probably not so important in this particular case, but 40 bytes per line can be a decent amount of RAM for some situations.
As an aside, you can also consider storing (at least for US addresses) the zip code and the +4 extension separately. In general, itβs useful to be able to generate reports by geographic region, and you often want to put everything in a zip code together rather than break it down by +4. At this point, it is useful not to try SUBSTR to output the first 5 characters for the zip code.
Justin Cave Nov 28 '08 at 21:41 2008-11-28 21:41
source share