Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.2/8.9.1) with ESMTP id LAA97119 for ; Fri, 19 Feb 1999 11:43:03 -0500 (EST) (envelope-from sferac@bo.nettuno.it) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.6/NETTuno 3.1) with ESMTP id RAA01430; Fri, 19 Feb 1999 17:42:58 +0100 (MET) Received: from rosso.sferacarta.com (bo.nettuno.it) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10Dtkz-00007h-00; Fri, 19 Feb 1999 17:30:29 +0000 Message-ID: <36CD920E.26F4FA3A@bo.nettuno.it> Date: Fri, 19 Feb 1999 17:32:14 +0100 From: "jose' soares" Organization: Sferacarta Software X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: Marc Grimme CC: "pgsql-sql@postgreSQL.org" Subject: Re: [SQL] SQL-Query 2 get primary key References: <36CD659A.438BE39B@atix.de> Content-Type: multipart/alternative; boundary="------------106FA8DE6251EF598BF8E770" --------------106FA8DE6251EF598BF8E770 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit You may query pg_indexes as in: select * from pg_indexes where tablename = 'test'; tablename|indexname|indexdef ---------+---------+----------------------------------------------------------------------- test |test_pkey|CREATE UNIQUE INDEX "test_pkey" ON "test" USING btree ("id" "int4_ops") (1 row) Marc Grimme ha scritto: > Hi, > > if I create a table like this: > CREATE TABLE test ( > id decimal(3) primary key, > name varchar(32)); > > how can I ask postgres which is the primary key from table test? > I hope to get something like "id is the primary key from table test.". > Any ideas > Marc > -- > ----------------------------------------------------------- > Marc Grimme - An der Muehle 1 - 85716 Unterschleissheim > Fon: +49 89 37 48 81 22 - +49 89 37 48 92 7 - 3/0 - > mail2: grimme@informatik.tu-muenchen.de, grimme@atix.de > ----------------------------------------------------------- > The UNIX Guru's View of Sex: > # unzip ; strip ; touch ; finger ; mount ; fsck ; more ; yes ; umount ; > sleep -- - Jose' - And behold, I tell you these things that ye may learn wisdom; that ye may learn that when ye are in the service of your fellow beings ye are only in the service of your God. - Mosiah 2:17 - --------------106FA8DE6251EF598BF8E770 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit You may query pg_indexes as in:

select * from pg_indexes where tablename = 'test';

tablename|indexname|indexdef
---------+---------+-----------------------------------------------------------------------
test     |test_pkey|CREATE UNIQUE INDEX "test_pkey" ON "test" USING btree ("id" "int4_ops")
(1 row)
 
 

Marc Grimme ha scritto:

Hi,

if I create a table like this:
CREATE TABLE test (
   id decimal(3) primary key,
   name varchar(32));

how can I ask postgres which is the primary key from table test?
I hope to get something like "id is the primary key from table test.".
Any ideas
Marc
--
-----------------------------------------------------------
Marc Grimme - An der Muehle 1 - 85716 Unterschleissheim
Fon: +49 89 37 48 81 22 - +49 89 37 48 92 7 - 3/0 -
mail2: grimme@informatik.tu-muenchen.de, grimme@atix.de
-----------------------------------------------------------
The UNIX Guru's View of Sex:
# unzip ; strip ; touch ; finger ; mount ; fsck ; more ; yes ; umount ;
sleep

--
                               - Jose' -

And behold, I tell you these things that ye may learn wisdom; that ye may
learn that when ye are in the service of your fellow beings ye are only
in the service of your God.                - Mosiah 2:17 -
  --------------106FA8DE6251EF598BF8E770--