Search Postgresql Archives

Re: how to find primary key field name?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday, October 11, 2011 3:54:09 pm J.V. wrote:
> 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?

Join against constraint_column_usage?:
http://www.postgresql.org/docs/9.1/interactive/infoschema-constraint-column-
usage.html

> 
> J.V.

-- 
Adrian Klaver
adrian.klaver@xxxxxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux