Re: [GENERAL] Is it possible to drop a column?

Поиск
Список
Период
Сортировка
От Jose' Soares
Тема Re: [GENERAL] Is it possible to drop a column?
Дата
Msg-id 35F9176F.A70A6DE5@sferacarta.com
обсуждение исходный текст
Ответ на Is it possible to drop a column?  ("sim" <sim@infomatch.com>)
Список pgsql-general
The SQL command is:

   ALTER TABLE table DROP [COLUMN] column { RESTRICT | CASCADE }

but PostgreSQL hasn't this feature yet.

Currently, to remove an existing column the table must be recreated
and reloaded. For example, if want to remove field "address" from table
"distributors"
you have to...


distributors:
----------------------
field    type
----------------------
did    DECIMAL(3)
name    VARCHAR(40)
address    VARCHAR(40)
----------------------


          CREATE TABLE temp AS SELECT did, city FROM distributors;
          DROP TABLE distributors;
          CREATE TABLE distributors (
               did      DECIMAL(3)  DEFAULT 1,
               name     VARCHAR(40) NOT NULL,
               );

          INSERT INTO distributors SELECT * FROM temp;
          DROP TABLE temp;


sim wrote:
>
> Hello,
>
> Is it possible to drop a column?
>
> Thanks.


Jose'

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

Предыдущее
От: Eric Marsden
Дата:
Сообщение: Re: [GENERAL] " \i filename "
Следующее
От: "Jose' Soares"
Дата:
Сообщение: Re: [GENERAL] How to set decimal(7,2)?