Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Thechewinggummonster
Starting Member
8 Posts |
Posted - 2014-03-23 : 20:26:16
|
I need to create a check constraint for an email column/field, where the field must contain an "@" symbol. Does sql (oracle or SQL in general) let you do this.1. Tried myself: ALTER TABLE Q_CustomerADD CONSTRAINT Q_chk_Cus_email CHECK (Cus_email LIKE '%@%');...butORA-02293: cannot validate (C3267304.Q_CHK_CUS_EMAIL) - check constraint violated2. Tried from a forum: alter table Q_CUSTOMER add constraint Q_Chk_cus_email check (Cus_email like '%_@__%.__%')...butORA-02293: cannot validate (C3267304.Q_CHK_CUS_EMAIL) - check constraint violated |
|
Thechewinggummonster
Starting Member
8 Posts |
Posted - 2014-03-23 : 20:53:01
|
Do I need to use a different programming language maybe.? Like PHP - which I haven't used for a while so hope not. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-03-23 : 22:19:06
|
I don't know about Oracle, perhaps if you can post at a oracle forums like orafaq.com or dbforums.com, you will get better response. By the way, if you have not noticed, SQLTeam.com is on Microsoft SQL Server KH[spoiler]Time is always against us[/spoiler] |
 |
|
Thechewinggummonster
Starting Member
8 Posts |
Posted - 2014-03-24 : 05:42:15
|
thanks for that. Thought most sql whether on Oracle or Microsoft is the same/ similar. |
 |
|
Monib
Starting Member
11 Posts |
Posted - 2014-03-24 : 05:58:16
|
HI, If the table has empty or no record then this error comes. Please insert values in table and then try again. Hope it will work fine. |
 |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-03-24 : 19:08:23
|
Could it be that there is data in the table which violates the check constraint?===============================================================================“Everyone wants a better life: very few of us want to be better people.” -Alain de Botton |
 |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2014-03-25 : 14:50:46
|
Are you trying to create a constraint on a table that already has the data? If yes, check if there are any violators, if can be fixed, fix it, else (if you're using SQL server) use "NoCheck" option which will prevent the constraint from being validated against existing rows, and to allow for the constraint to be added.CheersMIK |
 |
|
|
|
|
|
|