augi11
augi11

Reputation: 45

Does anybody know how to make a constraint that ensures there is a certain character in Oracle SQL?

I need a constraint where @ must be included in the email address. Any ideas? Using Oracle Live SQL if that helps.

Thank you in advance.

Upvotes: 1

Views: 38

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269633

You would use a check constraint:

alter table t add constraint chk_t_email
    check (email like '%@%');

Note: Full "format" validation of emails addresses is much more complicated -- and requires regular expressions. If you do some searching, you can probably find some already-built regular expressions for better validation.

Upvotes: 2

Related Questions