Re: delete column
От | Jochem van Dieten |
---|---|
Тема | Re: delete column |
Дата | |
Msg-id | 3CCABF98.3080600@oli.tudelft.nl обсуждение исходный текст |
Ответ на | Re: delete column (Bruce Momjian <pgman@candle.pha.pa.us>) |
Список | 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 по дате отправления: