From: | "Robby Slaughter" <webmaster(at)robbyslaughter(dot)com> |
---|---|
To: | "Suhadi" <suhadi(at)indosatcom(dot)net>, "SQL" <pgsql-sql(at)postgresql(dot)org> |
Subject: | RE: Delete coloumn |
Date: | 2001-08-07 04:35:53 |
Message-ID: | EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Unfortunately, there's no easy way to delete a column in a table in
PostgreSQL.
The standard SQL syntax is:
ALTER TABLE tablename DROP COLUMN columnname;
But I repeat, this is NOT supported in postgresql.
If you really need to delete a column you can always just create a new
table with an identical definition but WITHOUT the offending column, and
then
SELECT INTO it. Example:
CREATE TABLE sample (
id INTEGER,
data TEXT,
badcolumn DATE );
Now to delete the bad column table:
CREATE TABLE sample_copy (
id INTEGER,
data TEXT);
and then copy it all over:
SELECT id,data INTO sample_copy FROM sample;
and then you can DROP TABLE sample;
If you need the original table name, repeat the process of
creating a new table now and copying the data over.
Hope that helps!
-Robby Slaughter
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Suhadi
Sent: Monday, August 06, 2001 11:16 PM
To: SQL
Subject: [SQL] Delete coloumn
Please send to me how to delete coloumn in SQL.
Thank's
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
From | Date | Subject | |
---|---|---|---|
Next Message | Grant | 2001-08-07 04:42:45 | Re: Delete coloumn |
Previous Message | Grant | 2001-08-07 04:29:32 | Re: Delete coloumn |