Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Restricting the range of values in a field

Re: Restricting the range of values in a field

From: Alex Andriyashchenko <Oleksandr_A_at_yahoo.co.uk>
Date: Fri, 31 Jan 2003 03:33:41 -0800
Message-ID: <F001.00540361.20030131033341@fatcity.com>


Hello Aidan,

Thursday, January 30, 2003, 4:00:40 PM, you wrote:

AW> Is there any way you can specify that the only permissible values (is it
AW> called a domain?) that can be entered in varchar2 field in an Oracle
AW> table to, for example, A, B and C?

AW> We can restrict what values users can enter at the application level,
AW> but it would be nice to be able to also restrict what can be entered at
AW> the database level, in case other means of entering data are ever used
AW> or if the application layer fails, for whatever reason, to trap an AW> unwanted value.

AW> Thanks

Use CHECK constraint.

Like
ALTER TABLE a1
ADD CONSTRAINT CHECK column1 IN ('A','B','C')

--

Best regards,

 Alex                            mailto:Oleksandr_A_at_yahoo.co.uk

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Alex Andriyashchenko
  INET: Oleksandr_A_at_yahoo.co.uk

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Jan 31 2003 - 05:33:41 CST

Original text of this message

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