Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Implementation of boolean types.

Re: Implementation of boolean types.

From: Frank van Bortel <frank.van.bortel_at_gmail.com>
Date: Sun, 17 Jul 2005 13:04:26 +0200
Message-ID: <dbddka$fv8$1@news6.zwoll1.ov.home.nl>


Matthias Hoys wrote:

> "Frank van Bortel" <frank.van.bortel_at_gmail.com> wrote in message 
> news:db6cjj$obt$2_at_news1.zwoll1.ov.home.nl...
> 

>>Matthias Hoys wrote:
>>
>>>I would use a CHAR(1) column with a check constraint ('0' or '1').
>>>You could then link the table to a small lookup table with the
>>>description
>>>of the 0 and 1.
>>>0 = male
>>>1 = female
>>>
>>
>>No.
>>That would be '0' for male, and '1' for female. Character strings!
>>
>>
>>Why would you use a depericated char datatype, and not
>>a number?
>>
>>--
>>Regards,
>>Frank van Bortel
> 
> 
> CHAR(1) takes up less space ? 
> 
> 

I was afraid you were going to say that... Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production

SQL> create table t1 (col1 char(1));
Table created.

SQL> create table t2 (col1 varchar2(1)); Table created.

SQL> create table t3 (col1 number(1));
Table created.

SQL> insert into t1 values ('A');
1 row created.

SQL> insert into t2 values ('A');
1 row created.

SQL> insert into t3 values (0);
1 row created.

SQL> select dump(col1) from t1;
DUMP(COL1)



Typ=96 Len=1: 65

SQL> select dump(col1) from t2;
DUMP(COL1)



Typ=1 Len=1: 65

SQL> select dump(col1) from t3;
DUMP(COL1)



Typ=2 Len=1: 128

All I see, is a length of 1! And really, since when is space an argument again?
Are you willing to code bitands and xors, just to save a few byte, or will you just use the "Gender" column (Oh dear! One full column - bet we can use the "married" column, and bitwise operate on them, and save some space...).

Thought so.

-- 
Regards,
Frank van Bortel
Received on Sun Jul 17 2005 - 06:04:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US