pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ALTER TABLE and dropping a column
2+ messages / 2 participants
[nested] [flat]

* ALTER TABLE and dropping a column
@ 2002-02-07 22:25 Frank Joerdens <frank@joerdens.de>
  2002-02-07 23:22 ` Re: ALTER TABLE and dropping a column Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Frank Joerdens @ 2002-02-07 22:25 UTC (permalink / raw)
  To: pgsql-sql

7.1 at least doesn't seem to support a 'DROP COLUMN' command as in

ALTER TABLE foo DROP COLUMN bar;

Is there a way to do that manually and safely, e.g. by manipulating
pg_class or pg_attribute? I found a couple of threads about it dating
from way back in summer 2000 and early 2001, but nothing conclusive.

Thanks, Frank



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

* Re: ALTER TABLE and dropping a column
  2002-02-07 22:25 ALTER TABLE and dropping a column Frank Joerdens <frank@joerdens.de>
@ 2002-02-07 23:22 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2002-02-07 23:22 UTC (permalink / raw)
  To: Frank Joerdens <frank@joerdens.de>; pgsql-sql

Frank,

> ALTER TABLE foo DROP COLUMN bar;
> 
> Is there a way to do that manually and safely, e.g. by manipulating
> pg_class or pg_attribute? I found a couple of threads about it dating
> from way back in summer 2000 and early 2001, but nothing conclusive.

At this time, I would strongly recommend one of two approaches:

If the table has multiple constraints and other dependant objects:
1. pg_dump the database.
2. Edit the table definition and the data for the table from the
 pg_dump file.
3. Restore the database from pg_dump

If it doesn't:
1. Select the data for columns you want to keep into a new holding
 table.
2. Drop and re-build the table with the correct columns.
3. Insert the data from the holding table into the re-build table.
4. Drop the holding table.

It's a pain, I know, but not nearly the pain you will suffer if you
 start mucking with the system tables ...

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



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


end of thread, other threads:[~2002-02-07 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-07 22:25 ALTER TABLE and dropping a column Frank Joerdens <frank@joerdens.de>
2002-02-07 23:22 ` Josh Berkus <josh@agliodbs.com>

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