Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can Check Constraints be Reused for Multiple Columns?
xhoster_at_gmail.com wrote:
> "GeoPappas" <PappasG_at_gmail.com> wrote:
> > I have a bunch of columns that are a CHAR(1) and should only contain
> > "Y" (for Yes) and "N" (for No).
> >
> > Instead of creating a separate check constraint for each and every
> > column, is there a way to set up one check constraint and reuse it for
> > multiple columns?
>
> Why? Do you think that Oracle has a finite bag of check constraints and
> that it might run out?
:) Amusing answer, but it rather suggests that just because Oracle doesn't offer something, it would not be useful. "Code reuse" is generally considered a Good Thing, so why not with constraints? As someone else said earlier, this would be provided if Oracle supported domains so that instead of...
CREATE TABLE T
( col1 VARCHAR(1) CHECK (col1 IN ('Y','N')) , col2 VARCHAR(1) CHECK (col2 IN ('Y','N')) , col3 VARCHAR(1) CHECK (col3 IN ('Y','N'))...
... you could do this:
CREATE TABLE T
( col1 yn
, col2 yn
, col3 yn
...
, col99 yn
);
That would be cool, would it not? Received on Thu Aug 11 2005 - 06:32:21 CDT
![]() |
![]() |