Re: Changing column modifiers?

From: "Henshall, Stuart - WCP" <SHenshall(at)westcountrypublications(dot)co(dot)uk>
To: "'Arne Weiner'" <aswr(at)gmx(dot)de>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Changing column modifiers?
Date: 2001-09-11 08:47:02
Message-ID: E2870D8CE1CCD311BAF50008C71EDE8E01F746B5@MAIL_EXCHANGE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

ALTER TABLE authors ADD CHECK (NOT authorfirstname = NULL);
Should that be:
ALTER TABLE authors ADD CHECK (NOT authorfirstname IS NULL);
?
Anyway, how about something like the following:
UPDATE pg_attribute SET attnotnull='t' WHERE attname='field_name' AND
attrelid in (SELECT pg_class.oid FROM pg_class WHERE relkind='r' AND
relname='table_name');
Where field_name is the field name and table_name is the table name.
Hope this helps,
- Stuart

> -----Original Message-----
> From: Arne Weiner [SMTP:aswr(at)gmx(dot)de]
> Sent: Monday, September 10, 2001 10:06 AM
> To: pgsql-admin(at)postgresql(dot)org
> Subject: Re: Changing column modifiers?
>
>
> It seems that it is not possible to alter column constraints and
> table constraints do not include NOT NUL.
> But you can use CHECK as workaround:
>
> ALTER TABLE authors ADD CHECK (NOT authorfirstname = NULL);
>
> Arne.
>
> Tim Boring wrote:
> >
> > Can you change a column modifier after you've created the table? For
> > example, I have a table called "authors" with the following columns:
> > authorid, authorfirstname, authorlastname, authormi, statecode, country,
> > born, deceased.
> >
> > When I created the table, I forgot to make the "authorfirstname" and
> > "authorlastname" columns NOT NULL. I've looked at ALTER TABLE but I
> > don't see a way to use it to add NOT NULL...maybe I'm just missing the
> > obvious?
> >
> > Any help/suggestions are appreciated.
> >
> > Thanks,
> > Tim
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html

Browse pgsql-admin by date

  From Date Subject
Next Message Nick Fankhauser 2001-09-11 11:04:47 Can't get postmaster to restart after removing WAL files
Previous Message Lee Harr 2001-09-11 00:27:17 Re: Changing column modifiers?