Re: ALTER TABLE & NOT NULL

From: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ALTER TABLE & NOT NULL
Date: 2002-04-06 20:43:23
Message-ID: Pine.NEB.4.43.0204061442220.3593-100000@ns01.minnesota.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 6 Apr 2002, Joe Conway wrote:

> Thomas T. Thai wrote:
> > How do you alter a column so that it uses NOT NULL? I tried:
> >
> > alter table auth_users alter email set default not null;
> >
> > ERROR: Column "email" is of type character varying but default expression
> > is of type boolean
> > You will need to rewrite or cast the expression
> >
>
> I think you have to add a table constraint to do that. Something like:
>
> ALTER TABLE auth_users ADD CONSTRAINT auth_users_email CHECK (email is
> not null);

is this also what happens at the time of table creation when one specifies
that a column is to be NOT NULL?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-04-06 21:30:35 Re: ALTER TABLE & NOT NULL
Previous Message Joe Conway 2002-04-06 19:28:59 Re: ALTER TABLE & NOT NULL