From: | Jochem van Dieten <jochemd(at)oli(dot)tudelft(dot)nl> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: delete column |
Date: | 2002-04-27 15:11:20 |
Message-ID: | 3CCABF98.3080600@oli.tudelft.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
[retry with correct address]
Bruce Momjian wrote:
>
> FAQ updated to take advantage of rollback-able DROP TABLE:
>
> 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;
Depending on the dataset and the dominant query types I frequently add
an ORDER BY clause to force a sort on the data as it resides on the
disk. Not very usefull for datasets that change a lot, but it can help
for some queries.
BEGIN;
LOCK TABLE old_table;
SELECT ... -- select all columns but the one you want to remove
INTO TABLE new_table
FROM old_table
ORDER BY dominant_column;
DROP TABLE old_table;
ALTER TABLE new_table RENAME TO old_table;
COMMIT;
Jochem
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-04-27 15:14:50 | Re: creating a dump |
Previous Message | Tom Lane | 2002-04-27 15:08:59 | Re: delete column |