Re: Alter table

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: Alter table
Дата
Msg-id Pine.LNX.4.33.0403101052100.10418-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Alter table  ("David" <de4@kent.ac.uk>)
Список pgsql-sql
On Wed, 10 Mar 2004, David wrote:

> Ok another very newbie question. How can i change the data type a column can
> accept? at the moment it will only take character(7) i want to change it to
> varchar(30), but i cant figure how, ideas?

While there are ways to tinker with the system catalogs to change between 
different text types / lengths, none of these are "officially supported" 
and may well screw up your database if you do something wrong.  I believe 
the archives likely have this question over and over in them.

The proper way to do this is to make a new column, put the old column in 
it, and then drop the old column:

create table test (a char(7));
insert a few thousand lines to test...;
begin;
alter table test add column b varchar(30);
update test set b=a;
alter table test drop column a;
commit; (or rollback; should things go horribly wrong...)
vacuum full test;




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

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: designer tool connect to PostgreSQL
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: Inserting data in a table using sub-selects