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: Newbie Question - constrain input info

Re: Newbie Question - constrain input info

From: Eric Givler <egivler_at_flash.net>
Date: 2000/07/21
Message-ID: <tv1e5.292$9P1.13353@news.flash.net>#1/1

SQL> create table cars (cartype varchar2(10) );

Table created.

SQL> desc cars

 Name                            Null?    Type
 ------------------------------- -------- ----
 CARTYPE                                  VARCHAR2(10)

SQL> alter table cars
  2 add constraint ck_cars_cartype check (cartype in ('small','medium','large') );

Table altered.

SQL> insert into cars values ('big');
insert into cars values ('big')
*
ERROR at line 1:
ORA-02290: check constraint (GIVLER.CK_CARS_CARTYPE) violated

SQL> insert into cars values ('small');

1 row created.

Note that the check constraint could have been added at table creation. You could also create another table that holds these car sizes and create a Foreign key on CARS to Carsizes.

Good luck.

<timatlanta_at_my-deja.com> wrote in message news:8l8589$ekq$1_at_nnrp1.deja.com...
> Help! I need the syntax to restrict input into a column in a table.
>
> I'm guessing something like :
> CONSTRAIN CARS.car_size = "small" or
> CONSTRAIN CARS.car_sizi = "large"
>
> or something like that. I haven't got a clue, but I'm tryin'
>
>
> Thanks,
>
> Tim
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Fri Jul 21 2000 - 00:00:00 CDT

Original text of this message

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