Re: ALTER TABLE & NOT NULL - Mailing list pgsql-general

From Joe Conway
Subject Re: ALTER TABLE & NOT NULL
Date
Msg-id 3CAF4C7B.1050202@joeconway.com
Whole thread Raw
In response to ALTER TABLE & NOT NULL  ("Thomas T. Thai" <tom@minnesota.com>)
Responses Re: ALTER TABLE & NOT NULL
List pgsql-general
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);

Joe



pgsql-general by date:

Previous
From: "Thomas T. Thai"
Date:
Subject: ALTER TABLE & NOT NULL
Next
From: "Thomas T. Thai"
Date:
Subject: Re: ALTER TABLE & NOT NULL