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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to implement DOMAINs?

Re: How to implement DOMAINs?

From: andrewst <member14183_at_dbforums.com>
Date: 7 Apr 2003 10:16:45 GMT
Message-ID: <2737150.1049710927@dbforums.com>

Originally posted by Johann Sander
> Hello everybody,
>
> just came across the question how to implement SQL domains in ORACLE.
> What I would like to do is something like this:
>
> CREATE DOMAIN AREACODE AS CHAR(5) CONSTRAINT VALID_AREA CHECK (
> LENGTH(VALUE)=5 )
>
> Any ideas?
>
> Johann

Unfortunately, Oracle doesn't support the DOMAIN syntax. It does have user-defined TYPEs, but these don't address the issue of specifying constraints on the data values: you can only create constraints on columns, not on TYPEs.

BTW, your check constraint would not work as intended, since CHAR values are always automatically blank-padded to their full length anyway:

SQL> create table t ( code char(5) check (length(code) = 5));

Table created.

SQL> insert into t values ('x');

1 row created.

--
Posted via http://dbforums.com
Received on Mon Apr 07 2003 - 05:16:45 CDT

Original text of this message

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