Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D75776379C2 for ; Thu, 16 Apr 2009 17:01:32 -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 65552-05-4 for ; Thu, 16 Apr 2009 17:01:27 -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 3950F635BFF for ; Thu, 16 Apr 2009 17:01:30 -0300 (ADT) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id A87BE39496A; Thu, 16 Apr 2009 17:00:42 -0300 (ART) Message-ID: <49E798A3.2020805@fmed.uba.ar> Date: Thu, 16 Apr 2009 17:44:19 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql@postgresql.org Subject: Re: finding UNIQUES in information_schema References: <49E787FC.8020909@fmed.uba.ar> <28152.1239909139@sss.pgh.pa.us> In-Reply-To: <28152.1239909139@sss.pgh.pa.us> 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/97 X-Sequence-Number: 32443 Tom Lane wrote: > Gerardo Herzig writes: >> 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. > > No, they contain information about constraints, period. How did you > create those indexes? If you made them via SQL-standard PRIMARY KEY or > UNIQUE constraint syntax, they should show in the information_schema. > Otherwise not. > > regards, tom lane > Well, i just dont get it. Official docs from 8.2 says: """ The view key_column_usage identifies all columns in the current database that are restricted by some *unique*, *primary key*, or foreign key constraint. Check constraints are not included in this view. Only those columns are shown that the current user has access to, by way of being the owner or having some privilege. """ Well, damn, lets create some UNIQUE edatos=# CREATE UNIQUE INDEX aluestud_alu_cod_anifm on aluestud (alucod, codcarr1, anifm); CREATE INDEX edatos=#\d aluestud [...] Indexes: "estud_idx1" PRIMARY KEY, btree (alucod, codcarr1) "aluestud_alu_cod_anifm" UNIQUE, btree (alucod, codcarr1, anifm) And... edatos=# select table_name, constraint_name, column_name from information_schema.key_column_usage where table_name='aluestud'; table_name | constraint_name | column_name ------------+-----------------+------------- aluestud | estud_idx1 | alucod aluestud | estud_idx1 | codcarr1 (2 rows) Damn, im that idiot? Or should i get the UNIQUE i have just defined also?