Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g17NMhE47940 for ; Thu, 7 Feb 2002 18:22:43 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.2) with HTTP id 687910; Thu, 07 Feb 2002 15:22:43 -0800 From: "Josh Berkus" Subject: Re: ALTER TABLE and dropping a column To: Frank Joerdens , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.2 Date: Thu, 07 Feb 2002 15:22:43 -0800 Message-ID: In-Reply-To: <20020207232512.D6766@superfly.archi-me-des.de> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200202/88 X-Sequence-Number: 6516 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