| From: | Kevin Breit <mrproper(at)ximian(dot)com> |
|---|---|
| To: | "Christian H(dot) Stork" <cstork(at)ics(dot)uci(dot)edu> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Evolving databases (eg deleting columns) |
| Date: | 2002-07-27 22:20:23 |
| Message-ID: | 1027808423.31938.12.camel@kbreit.lan |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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.
--
Kevin Breit <mrproper(at)ximian(dot)com>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2002-07-27 23:05:39 | Re: Execution plan caching |
| Previous Message | Oliver Kohll | 2002-07-27 21:35:37 | Re: Execution plan caching |