Querying PostgreSQL to Find The Primary Key of a Table

Recently I found myself trying to programmatically find out which columns on a database table were acting as the primary key. It turns out that there is a relatively straightforward (and standard!) way of doing this.

Postgres provides the SQL-compliant Information Schema database, which contains useful table information, including indices. As I understand it, much of the information you're looking for can be obtained through this schema. And in some ways the table structure (and subsequen...

 •  0 comments  •  flag
Share on Twitter
Published on October 25, 2015 19:50
No comments have been added yet.