zazaza
zazaza

Reputation: 9

How to allow only some characters in sql (oracle)

I just looked now for hours how to allow only the characters w,p,s,v in my column. I wrote it like that but there is only every time a fail.

ALTER TABLE Personal ADD 
CONSTRAINT Typ
CHECK (Typ like '%^[w,p,s,v]%');

ALTER TABLE Personal
DROP CONSTRAINT CHK_Typ;

I really need this help :(

Upvotes: 1

Views: 391

Answers (1)

Littlefoot
Littlefoot

Reputation: 143103

How about

alter table personal add constraint ch_typ check (translate(typ, '.wpsv', '.') is null);

Upvotes: 1

Related Questions