Re: [GENERAL] Is it possible to drop a column? - Mailing list pgsql-general

From Jose' Soares
Subject Re: [GENERAL] Is it possible to drop a column?
Date
Msg-id 35F9176F.A70A6DE5@sferacarta.com
Whole thread Raw
In response to Is it possible to drop a column?  ("sim" <sim@infomatch.com>)
List 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 by date:

Previous
From: Eric Marsden
Date:
Subject: Re: [GENERAL] " \i filename "
Next
From: "Jose' Soares"
Date:
Subject: Re: [GENERAL] How to set decimal(7,2)?