Re: delete column - Mailing list pgsql-general

From Jochem van Dieten
Subject Re: delete column
Date
Msg-id 3CCABF98.3080600@oli.tudelft.nl
Whole thread Raw
In response to Re: delete column  (Bruce Momjian <pgman@candle.pha.pa.us>)
List 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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: delete column
Next
From: Tom Lane
Date:
Subject: Re: creating a dump