hi,
from mysql:
field enum('a','b','c') default null,
i translated this as:
field varchar(2) check (field in (null,'a','b','c')),
is it necessary to put the 'null' in the check condition? if not will pg
permit you to enter a null value in the field?
regards
kg
---(en
On Sat, 11 Dec 2004 10:30:55 +0530, Kenneth Gonsalves
<[EMAIL PROTECTED]> wrote:
> hi,
>
> from mysql:
>
> field enum('a','b','c') default null,
>
> i translated this as:
>
> field varchar(2) check (field in (null,'a','b','c')),
>
> is it necessary to put the 'null' in the check condition? if
On Sat, 11 Dec 2004, Ian Barwick wrote:
> (Oddly enough, putting the NULL in the CHECK constraint seems
> to make the constraint worthless:
> test=> create table consttest (field varchar(2) check (field in
> (null, 'a','b','c')));
> CREATE TABLE
> test=> insert into consttest values ('xx');
> INS
On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote:
> On Sat, 11 Dec 2004, Ian Barwick wrote:
>
> > (Oddly enough, putting the NULL in the CHECK constraint seems
> > to make the constraint worthless:
> > test=> create table consttest (field varchar(2) check (field in
> > (null, 'a','b','c')))
On Sat, 11 Dec 2004, Rod Taylor wrote:
> On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote:
> > On Sat, 11 Dec 2004, Ian Barwick wrote:
> >
> > > (Oddly enough, putting the NULL in the CHECK constraint seems
> > > to make the constraint worthless:
> > > test=> create table consttest (field v
On Sat, 11 Dec 2004 07:47:51 -0800 (PST), Stephan Szabo
<[EMAIL PROTECTED]> wrote:
> On Sat, 11 Dec 2004, Ian Barwick wrote:
>
> > (Oddly enough, putting the NULL in the CHECK constraint seems
> > to make the constraint worthless:
> > test=> create table consttest (field varchar(2) check (field i
Ian Barwick <[EMAIL PROTECTED]> writes:
> What I still don't quite understand is why IN in a CHECK context is
> handled differently to say: select 1 where 'x' in (null,'a','b','c') ?
> This could be a bit of a gotcha for anyone constructing a constraint
> similar to the original poster's and not
Kenneth,
> i translated this as:
>
> field varchar(2) check (field in (null,'a','b','c')),
While this isn't the question you asked, might I encourage you to use DOMAINs
instead? I.e.:
CREATE DOMAIN abc_col AS TEXT
CHECK VALUE IN ( 'a', 'b', 'c' );
Then you declare the table as:
tabl
Ian Barwick <[EMAIL PROTECTED]> writes:
> (Oddly enough, putting the NULL in the CHECK constraint seems
> to make the constraint worthless:
> test=> create table consttest (field varchar(2) check (field in
> (null, 'a','b','c')));
> CREATE TABLE
> test=> insert into consttest values ('xx');
> INSE