changing column type

Поиск
Список
Период
Сортировка
От Claudio Lapidus
Тема changing column type
Дата
Msg-id BAY7-DAV23CrsAWABNv000110a4@hotmail.com
обсуждение исходный текст
Ответы Re: changing column type
Список pgsql-general
I need to modify a column which is currently defined as varchar(30) to
varchar(40). I can see from the docs (and trial) that I cannot directly
alter a column this way, so I intend to do the following:

ALTER TABLE t1 ADD COLUMN duplicate varchar(40);
UPDATE t1 SET duplicate=original;
ALTER TABLE t1 DROP COLUMN original;
ALTER TABLE t1 RENAME duplicate TO original;

But I'm worried about messing up things if I run this queries while the
database is live, i.e. there are other processes writing to the table. Now,
if I enclose the above into a BEGIN/COMMIT pair, would you say it is safe to
run concurrently with other transactions?

TIA,
cl.


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

Предыдущее
От: Francisco J Reyes
Дата:
Сообщение: Domains (Was [PERFORM] Views With Unions)
Следующее
От: Mat Proud
Дата:
Сообщение: pg_stat_activity