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

Поиск
Список
Период
Сортировка
От Lorenzo Huerta
Тема Re: [GENERAL] Is it possible to drop a column?
Дата
Msg-id 19980913192554.18596.rocketmail@send103.yahoomail.com
обсуждение исходный текст
Ответы Re: [GENERAL] Is it possible to drop a column?  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Список pgsql-general

Well this should also work as well, and it will reduce the heartache.

  say you have a table foo, with columns A,B,C already created. Then
you want to remove column C as you don't need the data anymore.

 So you can do this:

    select A,B into table bar from foo, and it will create a brand new
table called bar , with the attribs for A & B the same as in foo, of
course with all your data included.

-lorenzo


---Jose' Soares <jose@sferacarta.com> wrote:
>
> 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'
>
>

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Предыдущее
От: prlw1@cam.ac.uk (Patrick Welche)
Дата:
Сообщение: Odd termination
Следующее
От: Lincoln Spiteri
Дата:
Сообщение: Readin money type into java BigDecimals