Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C90D863385B for ; Thu, 16 Apr 2009 15:50:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 50029-05 for ; Thu, 16 Apr 2009 15:50:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by mail.postgresql.org (Postfix) with ESMTP id 67C2763285D for ; Thu, 16 Apr 2009 15:50:31 -0300 (ADT) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id 36F17394A42 for ; Thu, 16 Apr 2009 15:49:42 -0300 (ART) Message-ID: <49E787FC.8020909@fmed.uba.ar> Date: Thu, 16 Apr 2009 16:33:16 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: finding UNIQUES in information_schema Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/92 X-Sequence-Number: 32438 Hi all. Im failing while trying to obtain some metainfo from information_schema. Acording to the docs, constraint_column_usage and key_column_usage views contains some information about constraints and indexes. See: Table "public.almatnov" Column | Type | Modifiers -------------+------------------------+-------------------------------- formu | integer | alucod | integer | default 0 codcarr | character varying(3) | default ''::character varying anifm | character varying(2) | default 20 comentarios | text | default ''::text Indexes: "almatnov_alucod_codcarr_idx" UNIQUE, btree (alucod, codcarr) "almatnov_codcarr_alucod" UNIQUE, btree (alucod, codcarr) And now: ematerias=# SELECT * from information_schema.constraint_table_usage where table_name='almatnov'; table_catalog | table_schema | table_name | constraint_catalog | constraint_schema | constraint_name ---------------+--------------+------------+--------------------+-------------------+----------------- (0 rows) ematerias=# SELECT * from information_schema.key_column_usage where table_name='almatnov'; constraint_catalog | constraint_schema | constraint_name | table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint --------------------+-------------------+-----------------+---------------+--------------+------------+-------------+------------------+------------------------------- (0 rows) 1) Im a doing anything wrong? 2) It is safe to extract metainfo from pg_catalog? Thanks! Gerardo