Re: Drop NOT NULL constraint !!! - Mailing list pgsql-general

From Mario Weilguni
Subject Re: Drop NOT NULL constraint !!!
Date
Msg-id 200211210753.20466.mweilguni@sime.com
Whole thread Raw
In response to Drop NOT NULL constraint !!!  (Renê Salomão <rene@ibiz.com.br>)
List pgsql-general
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

pgsql-general by date:

Previous
From: "Henrik Steffen"
Date:
Subject: what's that error?
Next
From: Jean-Christian Imbeault
Date:
Subject: Re: bug: select date 'infinity' gives error