Re: ALTER TABLE & NOT NULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ALTER TABLE & NOT NULL
Date: 2002-04-07 01:52:04
Message-ID: 28105.1018144324@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joe Conway <mail(at)joeconway(dot)com> writes:
>> is this also what happens at the time of table creation when one specifies
>> that a column is to be NOT NULL?

> Not quite the same, but the net effect is.

The built-in NOT NULL constraint is more efficient than doing it with a
general-purpose CHECK expression (or should be, anyway, but I've not
tried to measure the performance difference).

> I think I remember some discussion around making a way to add a not null
> modifier, but I don't believe it can be done today.

Chris Kings-Lynne recently contributed code to support ALTER COLUMN SET
NOT NULL and DROP NOT NULL, which will enable turning the built-in
constraint on and off. It will be in 7.3.

> (Except, maybe by hacking the system tables directly - it seems to work
> for me, but that's always a risky proposition.

That's all that the ALTER code does ;-)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2002-04-07 04:24:35 Re: Porting from MySql - meta data issues
Previous Message Joe Conway 2002-04-06 21:30:35 Re: ALTER TABLE & NOT NULL