Skip site navigation (1) Skip section navigation (2)

Re: newbie: Column CHECK(col contains '@') ?

From: john-paul delaney <jp(at)justatest(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: newbie: Column CHECK(col contains '@') ?
Date: 2002-05-12 23:21:05
Message-ID: Pine.LNX.4.21.0205122114590.1508-100000@justatest.com (view raw or flat)
Thread:
Lists: pgsql-novice
Thanks Joel... that did the trick (even better than I had asked for).  
Forgive my ignorance, but it your solution a regular expression? 

Can anyone suggest a good source where I can read up on these (regex's) in relation to postgresql?

thanks again,
/j-p.


On Sun, 12 May 2002, Joel Burton wrote:

> > One column in my table contains email addresses - I want to check
> > that any value entered contains a '@'.  How do I create a
> > CONSTRAINT or CHECK to ensure this when creating the table?
> 
> create table em (
>   em text constraint is_email check (em like '%(at)%(dot)%')
> );
> 
> will work fine, assuming that this check (something @ something . something)
> is acceptable in your context as "looks like an email address"
> 
> - J.
> 
> Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
> Knowledge Management & Technology Consultant
> 


-----------------------
 JUSTATEST Art Online
  www.justatest.com




In response to

Responses

pgsql-novice by date

Next:From: Brian SchroederDate: 2002-05-12 23:30:19
Subject: Re: Relation does not exist
Previous:From: Joel BurtonDate: 2002-05-12 19:50:50
Subject: Re: newbie: Column CHECK(col contains '@') ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group