pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Delete coloumn
5+ messages / 4 participants
[nested] [flat]

* Delete coloumn
@ 2001-08-07 04:16  Suhadi <suhadi@indosatcom.net>
  0 siblings, 2 replies; 5+ messages in thread

From: Suhadi @ 2001-08-07 04:16 UTC (permalink / raw)
  To: pgsql-sql


Please send to me how to delete coloumn in SQL.
Thank's



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Delete coloumn
@ 2001-08-07 04:29  Grant <grant@conprojan.com.au>
  parent: Suhadi <suhadi@indosatcom.net>
  1 sibling, 1 reply; 5+ messages in thread

From: Grant @ 2001-08-07 04:29 UTC (permalink / raw)
  To: Suhadi <suhadi@indosatcom.net>; +Cc: pgsql-sql

> Please send to me how to delete coloumn in SQL.
> Thank's

http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/

Bookmark the above URL.

ALTER TABLE is what you are looking for:

http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/sql-altertable.html




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* RE: Delete coloumn
@ 2001-08-07 04:35  Robby Slaughter <webmaster@robbyslaughter.com>
  parent: Suhadi <suhadi@indosatcom.net>
  1 sibling, 1 reply; 5+ messages in thread

From: Robby Slaughter @ 2001-08-07 04:35 UTC (permalink / raw)
  To: Suhadi <suhadi@indosatcom.net>; 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@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




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Delete coloumn
@ 2001-08-07 04:42  Grant <grant@conprojan.com.au>
  parent: Grant <grant@conprojan.com.au>
  0 siblings, 0 replies; 5+ messages in thread

From: Grant @ 2001-08-07 04:42 UTC (permalink / raw)
  To: Suhadi <suhadi@indosatcom.net>; +Cc: pgsql-sql

My response was incorrect! That's what you get for using phppgadmin all
day everyday. A transparent feeling that there is alter table drop column
support in postgresql :) Sorry.

> > Please send to me how to delete coloumn in SQL.
> > Thank's
> 
> http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/
> 
> Bookmark the above URL.
> 
> ALTER TABLE is what you are looking for:
> 
> http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/sql-altertable.html




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* RE: Delete coloumn
@ 2001-08-07 08:13  Grigoriy G. Vovk <grigoriy.vovk@linustech.com.cy>
  parent: Robby Slaughter <webmaster@robbyslaughter.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Grigoriy G. Vovk @ 2001-08-07 08:13 UTC (permalink / raw)
  To: Robby Slaughter <webmaster@robbyslaughter.com>; +Cc: Suhadi <suhadi@indosatcom.net>; pgsql-sql

Aug 6, 23:35 -0500, Robby Slaughter wrote:

> 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;

It is not correct. This statement used to _create_ _new_ table.
Correct is:
insert into sample_copy select id, data 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

my best regards,
----------------
Grigoriy G. Vovk




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2001-08-07 08:13 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-08-07 04:16 Delete coloumn Suhadi <suhadi@indosatcom.net>
2001-08-07 04:29 ` Grant <grant@conprojan.com.au>
2001-08-07 04:42   ` Grant <grant@conprojan.com.au>
2001-08-07 04:35 ` Robby Slaughter <webmaster@robbyslaughter.com>
2001-08-07 08:13   ` Grigoriy G. Vovk <grigoriy.vovk@linustech.com.cy>

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