RE: Delete coloumn

Поиск
Список
Период
Сортировка
От Robby Slaughter
Тема RE: Delete coloumn
Дата
Msg-id EPEHLKLEHAHLONFOKNHNEEOODDAA.webmaster@robbyslaughter.com
обсуждение исходный текст
Ответ на Delete coloumn  ("Suhadi" <suhadi@indosatcom.net>)
Ответы RE: Delete coloumn
Список 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Grant
Дата:
Сообщение: Re: Delete coloumn
Следующее
От: Grant
Дата:
Сообщение: Re: Delete coloumn