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

From: "Jose' Soares" <jose(at)sferacarta(dot)com>
To: sim(at)infomatch(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Is it possible to drop a column?
Date: 1998-09-11 12:28:31
Message-ID: 35F9176F.A70A6DE5@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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'

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jose' Soares 1998-09-11 12:33:40 Re: [GENERAL] How to set decimal(7,2)?
Previous Message Eric Marsden 1998-09-11 09:52:11 Re: [GENERAL] " \i filename "