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

Поиск
Список
Период
Сортировка
Искать
От
Joel Burton
Тема
Re: newbie: Column CHECK(col contains '@') ?
Дата
в 15:51:59
Msg-id
JGEPJNMCKODMDHGOBKDNEEMCCNAA.joel@joelburton.com
Ответ на
Список
Дерево обсуждения
newbie: Column CHECK(col contains '@') ? john-paul delaney <jp@justatest.com>
Re: newbie: Column CHECK(col contains '@') ? "Joel Burton" <joel@joelburton.com>
Re: newbie: Column CHECK(col contains '@') ? john-paul delaney <jp@justatest.com>
Re: newbie: Column CHECK(col contains '@') ? Andrew McMillan <andrew@catalyst.net.nz>
Re: newbie: Column CHECK(col contains '@') ? john-paul delaney <jp@justatest.com>
Re: newbie: Column CHECK(col contains '@') ? "Joel Burton" <joel@joelburton.com>
Re: newbie: Column CHECK(col contains '@') ? "Josh Berkus" <josh@agliodbs.com>
Re: newbie: Column CHECK(col contains '@') ? john-paul delaney <jp@justatest.com>
Re: newbie: Column CHECK(col contains '@') ? "Josh Berkus" <josh@agliodbs.com>
Re: newbie: Column CHECK(col contains '@') ? "Josh Berkus" <josh@agliodbs.com>
> 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 '%@%.%')
);

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@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

В списке pgsql-novice по дате отправления
От: G
Дата:
От: john-paul delaney
Дата:
FAQ