Re: alter table table add column

Поиск
Список
Период
Сортировка
От Nis Jørgensen
Тема Re: alter table table add column
Дата
Msg-id f8mq0h$9pg$1@sea.gmane.org
обсуждение исходный текст
Ответ на alter table table add column  (Ronald Rojas <ronald.rojas@gmail.com>)
Список pgsql-general
Ronald Rojas skrev:
> Hi,
>
> Anybody knows how to add column with reference to BEFORE or AFTER any
> given column? Let say here's my table structure:
>
>   Column  |       Type        | Modifiers
> ----------+-------------------+-----------
>  surname  | character varying |
>  lastname | character varying |
>  address   | character varying |
>
> And, I want to add the field name age with type integer after lastname
> OR before the address field. How to I do that?
>
> I would really appreciate your response.

Not tested.

ALTER TABLE foo ADD COLUMN age integer
ALTER TABLE foo ADD COLUMN address2 character varying;
UPDATE TABLE foo SET address2=address;
ALTER TABLE foo DROP COLUMN address;
ALTER TABLE foo RENAME COLUMN address2 TO address;


Nis

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

Предыдущее
От: "Peter Childs"
Дата:
Сообщение: Re: [NOVICE] alter table table add column
Следующее
От: "Victor Adolfsson"
Дата:
Сообщение: Performance problem with large resultsets (byte array 2200)