pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Changing NOT NULL condition on column
3+ messages / 3 participants
[nested] [flat]

* Changing NOT NULL condition on column
@ 2003-05-20 23:40  Bob Smith <bsmith@h-e.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Bob Smith @ 2003-05-20 23:40 UTC (permalink / raw)
  To: pgsql-admin


I need to change the not-null restriction on some columns in a table, 
and this doesn't seem to be possible with ALTER TABLE.  Is it safe to 
connect as superuser and update pg_attribute.attnotnull directly?  Or 
is there a different way to do this, other than dropping/re-creating 
the whole table?

I'm currently running 7.2.3, but will be upgrading soon so I'd like to 
know if this would work with 7.3 as well.

Thanks!

Bob Smith
Hammett & Edison, Inc.
bsmith@h-e.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Changing NOT NULL condition on column
@ 2003-05-21 03:58  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bob Smith <bsmith@h-e.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2003-05-21 03:58 UTC (permalink / raw)
  To: Bob Smith <bsmith@h-e.com>; +Cc: pgsql-admin

Bob Smith <bsmith@h-e.com> writes:
> I need to change the not-null restriction on some columns in a table, 
> and this doesn't seem to be possible with ALTER TABLE.  Is it safe to 
> connect as superuser and update pg_attribute.attnotnull directly?

Yeah.  I am not certain offhand that currently-running backends would
notice such a change, but at worst starting new sessions would cause
them to honor it.

> I'm currently running 7.2.3, but will be upgrading soon so I'd like to 
> know if this would work with 7.3 as well.

In 7.3 there are ALTER TABLE variants to handle this more cleanly.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Changing NOT NULL condition on column
@ 2003-05-24 16:31  eladio rodriguez <elarod_ad@hotmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: eladio rodriguez @ 2003-05-24 16:31 UTC (permalink / raw)
  To: bsmith@h-e.com; pgsql-admin

saludos.

en 7.3:
ALTER TABLE [ ONLY ] table [ * ]
    ALTER [ COLUMN ] column { SET | DROP } NOT NULL

en 7.2 no funciona.
tendrias que drop la columna y recrearla.


>From: Bob Smith <bsmith@h-e.com>
>To: pgsql-admin <pgsql-admin@postgresql.org>
>Subject: [ADMIN] Changing NOT NULL condition on column
>Date: Tue, 20 May 2003 16:40:34 -0700
>
>
>I need to change the not-null restriction on some columns in a table, and 
>this doesn't seem to be possible with ALTER TABLE.  Is it safe to connect 
>as superuser and update pg_attribute.attnotnull directly?  Or is there a 
>different way to do this, other than dropping/re-creating the whole table?
>
>I'm currently running 7.2.3, but will be upgrading soon so I'd like to know 
>if this would work with 7.3 as well.
>
>Thanks!
>
>Bob Smith
>Hammett & Edison, Inc.
>bsmith@h-e.com
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster

_________________________________________________________________
Charla con tus amigos en lĂ­nea mediante MSN Messenger: 
http://messenger.yupimsn.com/




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-05-24 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-20 23:40 Changing NOT NULL condition on column Bob Smith <bsmith@h-e.com>
2003-05-21 03:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-05-24 16:31 Re: Changing NOT NULL condition on column eladio rodriguez <elarod_ad@hotmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox