I've searched everywhere for a decent and logical CHECK
constraint to validate that an email is in the right format. So far I've found really long and unnecessary expressions like:
create table t (
email varchar2(320) check (
regexp_like(email, '[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]')
)
);
and
create table stk_t (
email varchar2(320) check (
email LIKE '%@%.%' AND email NOT LIKE '@%' AND email NOT LIKE '%@%@%'
)
);
Surely there is a simpler way? I'm using Oracle 11g database and SQL Developer IDE. This is what I have:
constraint Emails_Check check (Emails LIKE '%_@%_._%')
Can someone please let me know if this is the most efficient way of validating emails?