Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: NULL or 0 for a "FLAG_COLUMN"
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
![]() |
![]() |