Re: Strings vs. Numeric in Comparisons
Posted in 2000
--- "Steve Romankiw" <sromankiw@execrisk.com>
> wrote:
>As a rule of thumb, I generally define store numeric data as CHAR unless
>this value is going to be used within calculations.
>
>When it comes to performing SELECTs, does the optimizer prefer one over the
>other? In others words, should numeric data be defined as INTEGER and
>characters defined CHAR. Perhaps this is more a of data modeling question
>than a performance.
>
>So,
>
>SELECT name FROM employee WHERE id_char = '100';>vs.
>SELECT name FROM employee WHERE id_numeric = 100;>
>SteveR
The only numeric data I've seen done that way would be like phone numbers, zip codes and social security numbers or in cases where the numeric information is part of a larger character field as in a street address. I've also seen addresses split into a numeric portion defined as INT and a character portion.
To my mind it doesn't make sense to cripple the functionality that is inherant in the database. You have to add programming constraints to ensure that your numbers remain numeric and add overhead in the storage of any sizeable numerical information.
My question is, why do you do that?
carlos
==
Maintainer of the procrastinator's FAQ. Well, maybe tomorrow I will be.
_____________________________________________________________
Want a new web-based email account ? ---> http://www.firstlinux.net