X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88D9B3A3CEA for ; Tue, 9 Nov 2004 15:00:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45318-07 for ; Tue, 9 Nov 2004 14:59:57 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 8C9793A3C3D for ; Tue, 9 Nov 2004 14:59:59 +0000 (GMT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id iA9FUP5x004351; Tue, 9 Nov 2004 17:30:25 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id iA9FUPJR004347; Tue, 9 Nov 2004 17:30:25 +0200 Date: Tue, 9 Nov 2004 17:30:25 +0200 (EET) From: Achilleus Mantzios To: Giulio Orsero Cc: pgsql-sql@postgresql.org Subject: Re: Drop all indexes of a table w/o knowing the index names In-Reply-To: <20041109144039.1B2D313346@mail.golden.dom> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/83 X-Sequence-Number: 19402 O Giulio Orsero έγραψε στις Nov 9, 2004 : > 7.4.6 on Linux. > > I need a way to drop all indexes of a table without knowing the names of the > indexes. > > Say I have a table > > table1 > index1 > index2 > index3 > > I don't want to do > > drop index1; > drop index2; > drop index3; > > but I want > > drop if your are using default namespace (schema) % tcsh % foreach i ( `psql -t -q -c "SELECT ci.relname from pg_index i,pg_class ci,pg_class ct where i.indexrelid=ci.oid and i.indrelid=ct.oid and ct.relname='YOUR_TABLE_HERE'"` ) foreach? psql -c "drop index $i" foreach? end > > is this possible? I looked in the manual at pg_index, but couldn't build an > sql string to do it. > > Thanks > > -- -Achilleus