Re: Drop all indexes of a table w/o knowing the index names

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Giulio Orsero <giulioo(at)pobox(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Drop all indexes of a table w/o knowing the index names
Date: 2004-11-09 15:30:25
Message-ID: Pine.LNX.4.44.0411091727100.4167-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 <all indexes of table table1>

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Goutam Paruchuri 2004-11-09 15:34:42 Loading text data/binary data !!
Previous Message Theodore Petrosky 2004-11-09 15:24:57 Re: A transaction in transaction? Possible?