I'm using Oracle 11g, and trying to create a table define constraints on the creation.
I was trying to add check constraint to validate some information (like e-mail address, phone number, etc...)
Is there something in Oracle 11g that would allow me to do something like this?
constraint CK_CONSTRAINT_NAME check (EMAIL like 'REGEX')
^[a-zA-Z][a-zA-Z0-9_\.\-]+@([a-zA-Z0-9-]{2,}\.)+([a-zA-Z]{2,4}|[a-zA-Z]{2}\.[a-zA-Z]{2})$
WHERE
A check constraint follows the same syntax rules as conditions for a WHERE clause:
alter table foo
add constraint check_email
check (REGEXP_LIKE(email,'your_regex_goes_here','I'));
More details in the manual:
Edit:
There are however some restrictions on what you can actually use in a check constraint: