Re: Can a function determine whether a primary key constraint exists on a table? - Mailing list pgsql-general

From ptjm@interlog.com (Patrick TJ McPhee)
Subject Re: Can a function determine whether a primary key constraint exists on a table?
Date
Msg-id 12iu6ivjiti162f@corp.supernews.com
Whole thread Raw
In response to Re: Can a function determine whether a primary key constraint exists on a table?  ("Albe Laurenz" <all@adv.magwien.gv.at>)
List pgsql-general
In article <52EF20B2E3209443BC37736D00C3C1380AD5FEFF@EXADV1.host.magwien.gv.at>,
Albe Laurenz <all@adv.magwien.gv.at> wrote:

% >                                     How can I check for the
% > presence of constraints inside a function?
%
% select t.oid as tableid, t.relname as tablename,
%       c.oid as constraintid, conname as constraintname
% from pg_constraint c join pg_class t on (c.conrelid = t.oid);

or, perhaps simpler,

 select * from information_schema.table_constraints
  where constraint_type = 'PRIMARY KEY';

--

Patrick TJ McPhee
North York  Canada
ptjm@interlog.com

pgsql-general by date:

Previous
From: roopa perumalraja
Date:
Subject: Performance problem
Next
From: alexei.vladishev@gmail.com
Date:
Subject: Re: more anti-postgresql FUD