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

Home -> Community -> Usenet -> c.d.o.misc -> Re: NULL or 0 for a "FLAG_COLUMN"

Re: NULL or 0 for a "FLAG_COLUMN"

From: Martin T. <bilbothebagginsbab5_at_freenet.de>
Date: 6 Sep 2006 08:23:21 -0700
Message-ID: <1157556201.055729.120880@i3g2000cwc.googlegroups.com>


Thomas Kellerer wrote:
> On 06.09.2006 16:55 Martin T. wrote:
> > Hey all.
> >
> >>From a general ORACLE point of view (lets say 9i2 upwards), what would
> > be the preferred way of storing a true/false flag column.
> >
> > a) col MY_FLAG: NOT NULL, DEFAULT 0, Possible values: 1, 0
> > or
> > b) col MY_FLAG: Possible values 1, NULL
> >
> > There is some side effect of having NULL vs. 0 when using indexes,
> > right?
> > Any other ideas why the one or other might be better (Storage /
> > Performance / Indexing)?
>
> NULL means "undefined".
> I would _never_ use it to represent an actual "meaningful" value.
>
> So, I would always choose option a) together with a check constraint
> only allowing for 0,1 as the value.
>

Thomas - thank you.
Very valid point I guess. (Now that I think more about it, it will for example make IF questions on the column value easier.)

best,
Martin Received on Wed Sep 06 2006 - 10:23:21 CDT

Original text of this message

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