Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to implement DOMAINs?
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.comReceived on Mon Apr 07 2003 - 05:16:45 CDT