Re: how can we change definition of a table once created?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: how can we change definition of a table once created?
Дата
Msg-id Pine.BSF.4.21.0107082343100.86282-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на how can we change definition of a table once created?  (Bhuvan A <bhuvanbk@yahoo.com>)
Список pgsql-sql
On Mon, 9 Jul 2001, Bhuvan A wrote:

> can any one say how can we change the table definition once
> created?
> 
> say, we have a table with 1000s of records. if one needs
> to change the data type of particular column or if he
> needs to change the width of a column what should be
> done? 
> 
> As of now, i am copying the data to a file(COPY COMMAND) and
> creating a new table after deleting the old one and copying
> the content of that file to the new table. 
> 
> is it the only way to do it?

Not quite.  Right now, you will need to make a new table, but
you can use alter table rename and insert ... select to make your
life a little easier... Something like:

create table new ... ;
insert into new (...) select ... from old;
alter table old rename to old_backup;
alter table new rename to old;
(drop old_backup when you're sure it's safe)



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

Предыдущее
От: Bhuvan A
Дата:
Сообщение: how can we change definition of a table once created?
Следующее
От: Alvar Freude
Дата:
Сообщение: Returning multiple Rows from PL/pgSQL-Function