Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: VARCHAR2(1) vs CHAR(1) CORRECTED!
Ah, excuse me, but I was wrong on this. It was politely pointed out to me
that this was in dispute, and so we did an experiment this morning to check
this out. This was done on Oracle 8.1.6 on NT, but I have no reason to
suspect it is release or platform specific.
We created two tables, each with one column, the first with VARCHAR2(1) and the second CHAR(1). We inserted a row and analyzed the tables. The average row size was 5 bytes in both cases. So, contrary to what I have believed for some time, there is NO difference between VARCHAR2(1) and CHAR(1). A length field is apparently used for both VARCHAR2 and CHAR.
(Just for benefit of newer Oracle users on the list, for lengths greater than 1, this will not be true, as CHAR is a fixed length type and spaces will be saved. So CHAR(2) with one character saved is definitely larger than VARCHAR2(2) with one character saved.)
Mea culpa!
Marc Perkowitz
MTP Systems Consulting
In a message dated 6/27/00 1:14:29 PM Central Daylight Time, MTPConsulting writes:
<< That's correct.
Marc Perkowitz
MTP Systems Consulting
In a message dated 6/27/00 1:16:41 AM Central Daylight Time, KeesH_at_discoveryhealth.co.za writes:
<< Can someone please tell me which datatype uses up more diskspace : a VARCHAR2(1) or a CHAR(1) field. A VARCHAR2 field supposedly stores the data in the field plus the field length (1 + 1 byte) while a CHAR field only stores the data (1 byte). Received on Wed Jun 28 2000 - 14:06:35 CDT