Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Limit characters in a field
> Hi all,
> Is there some way to limit WHAT characters can be entered in to a field
> in an Oracle table?
> For eg., allow a field to have ONLY vowels (i.e., the characters
> a,e,i,o,u) and some punctuation marks (like single quotes, comma, double
> quotes, hyphen and a semicolon)?
> Thanks in advance,
> Krishna
Krishna,
In your case of 'only vowels', a check constraint will do:
create table test_ (
only_vowels varchar2(50) check
(translate(upper(only_vowels),':AEIOU',':') = ':')
);
insert into test_ values ('abc'); insert into test_ values ('io'); insert into test_ values (null); insert into test_ values ('u');
select * from test_;
drop table test_;
hth
Rene Nyffenegger
-- no sig todayReceived on Fri Feb 14 2003 - 13:20:27 CST
![]() |
![]() |