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: CHECK ConstraintsQ

Re: CHECK ConstraintsQ

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Fri, 05 Sep 2003 21:33:52 -0700
Message-ID: <1062822813.569285@yasure>


Hari Om wrote:

>Hi ORAPERTS (ORAcle xPERTS)
>
>How can I define a CHECK CONSTRAINT on a table for a field like zip
>code....?
>
>Here is what I am doing:
>create table test
>(
>state varchar2(5) check (state
>in('AL','AK','AZ','AR','CA','CO','CT','DE'))
>
>)
>
>but it seems that it freaks out....wonder why...? I tried using DOUBLE
>QUOTES also but in vain....what is a correct way?
>
>THANKS!
>
>

You should not be creating check constraints on any field in the create table statement. Create constraints after table creation in separate ALTER TABLE statements so that they can be named.

What you say you are doing ("define a CHECK CONSTRAINT on a table for a field like zip") and your example "check (state" don't correspond. But in either case a check constraint should not be used. Put the values into a table and create a foreign key.

Quick Note: From the number and content of your recent posts it appears that you may think these usenet groups are here to teach you Oracle and to do your work for you. They are not, we are not, and I am not. Please purchase a few books, bookmark tahiti.oracle.com, and take some classes. We are not a substitute for education and will not do your work for you unless you send us your paychecks. At the rate you are going you are going to quickly find your posts being ignored. I already detect some getting a bit testy and I understand why.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Fri Sep 05 2003 - 23:33:52 CDT

Original text of this message

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