Re: Evolving databases (eg deleting columns)

From: Oliver Kohll <oliver(at)gtwebmarque(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Evolving databases (eg deleting columns)
Date: 2002-07-27 23:53:30
Message-ID: 200207272353.30402.oliver@gtwebmarque.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You'll also have to recreate any triggers/referential integrity constraints

On Saturday 27 July 2002 10:20 pm, you wrote:
> On Thu, 2002-07-25 at 20:19, Christian H. Stork wrote:
> > My question: How can I evolve databases (ie deleting columns,
> > adding/changing/removing constraints, etc)?
>
> PostgreSQL doesn't support deleting columns (I've had this issue myself
> recently). However, there is a workaround. It is described at:
> http://postgresql.org/docs/faq-english.html#4.4
>
> It states:
>
>
> 4.4) How do you remove a column from a table?
> We do not support ALTER TABLE DROP COLUMN, but do this:
>
> BEGIN;
> LOCK TABLE old_table;
> SELECT ... -- select all columns but the one you want to remove
> INTO TABLE new_table
> FROM old_table;
> DROP TABLE old_table;
> ALTER TABLE new_table RENAME TO old_table;
> COMMIT;
>
> I hope this helps.

--
Regards,
Oliver

GT webMarque
+44(0)1792 655968 / 07808 678244 / oliver(at)gtwebmarque(dot)com

NOTE
No contracts may be concluded on behalf of GT webMarque by means of e-mail
communications. The contents of this e-mail are confidential to the
intended recipient at the e-mail address to which it has been addressed;
it may not be disclosed to or used by anyone other than this addressee,
nor may it be copied in any way. If received in error please return to
sender via e-mail.

DISCLAIMER
Please note that neither GT webMarque Ltd nor the sender accept any
responsibility for viruses transmitted via e-mail. It is your
responsibility to scan attachments (if any).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-07-28 01:14:18 Re: O'Reilly Interview on PostgreSQL
Previous Message Tom Lane 2002-07-27 23:12:10 Re: ExecEvalExpr: unknown expression type 704 problems...