pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robby Slaughter <webmaster@robbyslaughter.com>
To: Suhadi <suhadi@indosatcom.net>
To: SQL <pgsql-sql@postgresql.org>
Subject: RE: Delete coloumn
Date: Mon, 6 Aug 2001 23:35:53 -0500
Message-ID: <EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com> (raw)
In-Reply-To: <20010807041600.9821.qmail@mail.indosatcom.net>

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@postgresql.org
[mailto:pgsql-sql-owner@postgresql.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@postgresql.org




view thread (5+ messages)  latest in thread

Message-ID: <EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com>
Permalink:  ../EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com/
Also on:    postgresql.org/message-id/EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: webmaster@robbyslaughter.com, suhadi@indosatcom.net
  Subject: RE: Delete coloumn
  In-Reply-To: <EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox