how to find primary key field name?

From: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: how to find primary key field name?
Date: 2011-10-11 22:54:09
Message-ID: 4E94C911.6030003@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I have a table name, I know how to find the primary key constraint
name, but see no way to find the primary key field name.

select constraint_name from information_schema.tabale_constraints where
table_name = <table_name> and constraint_type = 'PRIMARY KEY';

will return the constraint name, but given the table_name and the
constraint_name, how do I find the database column/field name associated
with that primary key?

J.V.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sean Laurent 2011-10-11 23:00:17 Re: Postgres 9.01, Amazon EC2/EBS, XFS, JDBC and lost connections
Previous Message Sean Laurent 2011-10-11 22:41:10 Re: Postgres 9.01, Amazon EC2/EBS, XFS, JDBC and lost connections