Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id 07674475897 for ; Thu, 18 Jul 2002 10:22:07 -0400 (EDT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Thu Jul 18 16:22:04 2002 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id QAA12155; Thu, 18 Jul 2002 16:22:02 +0200 (METDST) From: Christoph Haller Message-Id: <200207181422.QAA13952@rodos> Subject: Re: How to find out if an index is unique? To: lutzeb@aeccom.com (Dirk Lutzebaeck) Date: Thu, 18 Jul 2002 16:22:00 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: <15669.16833.74916.773006@cayambe.core.aeccom.com>; from "Dirk Lutzebaeck" at Jul 17, 102 12:07 (noon) X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200207/282 X-Sequence-Number: 8660 Dirk, May be you can use this create view sesql_userindexes as SELECT upper(c.relname) AS TBL_NAME, upper(i.relname) AS IDX_NAME, CASE WHEN x.indisunique=false THEN 0 ELSE 1 END AS UNIQUE_FLAG, 1+ (CASE WHEN x.indkey[1]=0 THEN 0 ELSE 1 END)+(CASE WHEN x.indkey[2]=0 THEN 0 ELSE 1 END)+ (CASE WHEN x.indkey[3]=0 THEN 0 ELSE 1 END)+(CASE WHEN x.indkey[4]=0 THEN 0 ELSE 1 END)+ (CASE WHEN x.indkey[5]=0 THEN 0 ELSE 1 END)+(CASE WHEN x.indkey[6]=0 THEN 0 ELSE 1 END)+ (CASE WHEN x.indkey[7]=0 THEN 0 ELSE 1 END) AS IDXCOL_TOTAL, x.indkey AS COL_SEQ FROM pg_index x, pg_class c, pg_class i WHERE ((c.oid = x.indrelid) AND (i.oid = x.indexrelid)) and not (c.relname ~* 'pg_') ; select * from sesql_userindexes order by tbl_name, idx_name ; gives you detailed information about all user-defined indices. Regards, Christoph > > is there a way to ask the system tables if a given index was created > with the unique qualification? I don't want to insert data to try. >