ALTER TABLE DROP COLUMN

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: ALTER TABLE DROP COLUMN
Date: 2000-02-26 04:12:26
Message-ID: 200002260412.XAA14752@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Marc called me today to discuss ALTER TABLE DROP COLUMN options.

Our new idea is to do the ALTER TABLE DROP COLUMN in place in the
existing table, rather than make a new one and try and preserve all the
table attributes.

You can exclusively lock the table, then do a heap_getnext() scan over
the entire table, remove the dropped column, do a heap_insert(), then a
heap_delete() on the current tuple, making sure to skip over the tuples
inserted by the current transaction. When completed, remove the column
from pg_attribute, mark the transaction as committed (if desired), and
run vacuum over the table to remove the deleted rows.

Seems this would be a very clean implementation for 7.1. It also would
be roll-backable in cases where the operation failed half-way during the
process.

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Don Baccus 2000-02-26 05:15:13 Re: [HACKERS] LZTEXT for rule plan stings
Previous Message Jan Wieck 2000-02-26 03:06:05 Re: [HACKERS] LZTEXT for rule plan stings