| От | Thomas Kellerer |
|---|---|
| Тема | Re: How to convert integer to boolean in insert |
| Дата | |
| Msg-id | grdfei$dqc$1@ger.gmane.org обсуждение исходный текст |
| Ответ на | Re: How to convert integer to boolean in insert (Alvaro Herrera <alvherre@commandprompt.com>) |
| Список | pgsql-general |
Alvaro Herrera wrote on 06.04.2009 19:39: >> If that is a one-time thing, why not create the table with banned as an >> integer column and another boolean column (if your INSERTs are properly >> listing the column names), then after the import update the boolean to >> the casted integer value, drop the integer and rename the boolean? > > Actually it seems it would be better to create the table with only the > integer column, and later use ALTER TABLE / TYPE to change it. > Something like > > CREATE TABLE foo (banned integer); > > -- run inserts > > ALTER TABLE foo ALTER banned TYPE bool USING banned::bool; > > That way you don't end up with half a table of dead tuples. Yes I was worrying about that as well. Didn't know about the cast in the ALTER statement ;) Pretty cool. Thomas
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера