Re: Restrict values in an INTEGER column.

Re: Restrict values in an INTEGER column.

 

  

You should be able to add a "check constraint" with in (1,2)

alter table ... add constraint check_12 CHECK (in (1,2))

You should then later be able to only drop the constraint and
recreate it with in (1,2,3)
without having to drop the table.

alter table ... drop constraint check_12

alter table ... add constraint check_123 CHECK (in (1,2,3))


if you're only going to use small values, you might want to use
smallint instead of integer. (just a thought)

Guus


On 27-Sep-05, at 9:36 AM, Pedro Miguel Gonçalves wrote:

>
> Hi Guys,
>
> Currently working in DB2 v.7 fro Z/Os
>
> I have 2 questions:
>
> 1st question:
> ==========
>
> I need a table that will contain a column data-typed=INTEGER and
> that wil restrict its update or insert only with the values 1 and 2.
> Is that possible, I think so.
>
> Please tell me how to code that in my table.
>
>
> 2nd question:
> ==========
>
> If later I would want to ALTER the restriction on that same column
> to the values 1,2 and 3?
> That would make me drop a recreate my table? Or there's a way just
> ALTERing the column and REORG?
>
> Please tell me how to code that in my table too.
>
> Thanks in advance,
>
>
>
> ---------------------------------------------------------------------
> PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
> website: http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>


DB2 & UDB email list listserv db2-l LazyDBA home page