Re: how do you get there from here?

Поиск
Список
Период
Сортировка
От Michael P. Soulier
Тема Re: how do you get there from here?
Дата
Msg-id 4A0B1601.9030002@mitel.com
обсуждение исходный текст
Ответ на Re: how do you get there from here?  ("Michael P. Soulier" <michael_soulier@mitel.com>)
Ответы Re: how do you get there from here?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
Michael P. Soulier wrote:
> So, I'm working around it by creating the new columns with the default
> value that I want populated, and then resetting the default. This works,
> but it doesn't feel like a best practice.
>
> Can someone recommend a better way to say, consolidate 3 columns down to
> 2 and conditionally move contents around to the new columns, inside of a
> transaction involving ALTER TABLE calls?
>
> I'm just wondering if there is a better solution than what I've done.

In fact, I just ran into this again and I don't know, off the top of my
head, how to solve this one completely.

Postgres7 code:

BEGIN;
ALTER TABLE clients ADD COLUMN typelabel varchar(128);
UPDATE clients SET typelabel = settype;
UPDATE clients SET settype = 'Unknown';
ALTER TABLE clients ALTER COLUMN typelabel SET DEFAULT 'Unknown';
COMMIT;

Working Postgres8 code:

BEGIN;
ALTER TABLE clients ADD COLUMN typelabel varchar(128) DEFAULT 'Unknown';
COMMIT;

But this way I lose the copy of the settype column data over to the
typelabel column.

Can someone suggest a better way that doesn't hit this "pending trigger"
issue while in a transaction?

Thanks,
Mike
--
Michael P. Soulier <michael_soulier@mitel.com>, 613-592-2122 x2522
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein


Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Juan Camilo Marín
Дата:
Сообщение: Re: lack in psql console
Следующее
От: "WP Perquin"
Дата:
Сообщение: Re: regexp_matches problem