pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mario Weilguni <mweilguni@sime.com>
To: pgsql-general@postgresql.org
Subject: Re: Drop NOT NULL constraint !!!
Date: Thu, 21 Nov 2002 07:53:20 +0100
Message-ID: <200211210753.20466.mweilguni@sime.com> (raw)
In-Reply-To: <20021120170913.74176c82.rene@ibiz.com.br>
References: <20021120114805.C29739-100000@zoraida.natserv.net>
	<3DDBD5EE.4040804@intransa.com>
	<20021120170913.74176c82.rene@ibiz.com.br>

Am Mittwoch, 20. November 2002 20:09 schrieb RenX SalomXo:
>  Does anybody could tell me how to drop a constraint on a column where no
> name was provided to the constraint? How does Pg name constraints?
>
> Thanks

did you add a "CHECK" constraint, or did you use "NOT NULL" in the table definition? For the not null case it's easy:

update pg_attribute 
      set attnotnull=false
where attname='yourattributename'
   and attrelid=(select oid from pg_class where relname='mytable' and relkind='r');

If you added a check constraint, you have to remove the corresponding row from pg_relcheck
and decrement the attribute "relchecks" in pg_class for the table, but I won't do it without having 
a backup at hand.

Backup your data first.

Regards,
	Mario Weilguni



view thread (3+ messages)  latest in thread

Message-ID: <200211210753.20466.mweilguni@sime.com>
Permalink:  ../200211210753.20466.mweilguni@sime.com/
Also on:    postgresql.org/message-id/200211210753.20466.mweilguni@sime.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mweilguni@sime.com, pgsql-general@postgresql.org
  Subject: Re: Drop NOT NULL constraint !!!
  In-Reply-To: <200211210753.20466.mweilguni@sime.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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