Excellent Information
Muhammad Riaz Shahid, July 08, 2004 - 10:59 am UTC
<Quote>
I *hate* the char type, I suggest *never* consider using it for anything, not even a char(1).
</Quote>
So if i have to define a column which , i know, will take exactly one character (for example, Sex) and is not null, then would you still suggest to use varchar2(1) over char(1) ??? (or even number(1) i.e; 1=male, 2=female).
Also i heard that strings searching is faster than number searching (non-indexed)...whats your opinion about that ?
If you are given a choice to select the datatype of a column of length 1, among char(1),varchar2(1) and number(1), which one you would select ???
Regards
July 08, 2004 - 11:55 am UTC
yes, that is what I suggest.
why? because it just lets you pretend that CHAR doesn't even exist. gets you in the habit of never typing "char", but always typing "varchar2"
a char(1) and a varchar2(1) that is not null are *identical*
the bit about numbers is non sensible. first of all, it would be the worst thing in the world to store a number in a string. (well, on the list of the worst things in the world). If you are interested in the long winded "why" -- i wrote about it in "Effective Oracle by Design" -- it mucks up the data, mucks up the optimizer, no good ever comes from it.
A number is a varying string 'string'. It will take less bytes to store a number in a number than to store the number in a string. It will take more cpu cycles to search for the string '100010001001' than it would for the same number. In fact, with character sets and such - searching strings could be much more expensive, whereas a number is always done "binary".
as for your last question -- i would limit it to varchar2(1) and number(1) and the domain of values allowed would dictate (DICTATE, not suggest) the correct datatype.