From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Dan Browning <danb(at)cyclonecomputers(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Removing all NOT NULL constraints from multiple tables easily |
Date: | 2000-09-11 16:37:42 |
Message-ID: | Pine.BSF.4.10.10009110930450.11606-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
Yes, but you'll probably not like it... You can modify the
system tables to remove the not nulls. We don't yet have
the ALTER TABLE syntax for doing it...
You're usually better off dumping and reimporting, but I
believe the query below should do it if you really want to
try (make a safety dump first though)...
update pg_attribute set attnotnull='f' where
exists (select * from pg_class where pg_class.oid=attrelid
and pg_class.relname!~'^pg_') and attnotnull='t';
Stephan Szabo
sszabo(at)bigpanda(dot)com
On Mon, 11 Sep 2000, Dan Browning wrote:
> I would like to remove all NOT NULL constraints from my tables.
>
> I've tried ALTER TABLE, but I can't seem to get the syntax right, and the
> docs aren't clear to me.
> What is the correct syntax? If there's another way, short of manually
> recreating (dump, create, import) the tables, I'd love to hear it.
>
> Thanks,
>
> Dan Browning
> Network & Database Administrator
> Cyclone Computer Systems
>
From | Date | Subject | |
---|---|---|---|
Next Message | Zeljko Trogrlic | 2000-09-11 16:39:35 | Re: Column name case conversion |
Previous Message | Stephan Szabo | 2000-09-11 16:30:14 | Re: can't read SQL dump from MySQL |
From | Date | Subject | |
---|---|---|---|
Next Message | Webb Sprague | 2000-09-11 19:38:31 | Re: cat infile | translate all occurences of "NOT NULL" to "" |
Previous Message | WOLF, PATRICK | 2000-09-11 15:13:29 | RE: Removing all NOT NULL constraints from multiple tabl es easily |