Re: Can a function determine whether a primary key constraint exists on a table?

From: ptjm(at)interlog(dot)com (Patrick TJ McPhee)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Can a function determine whether a primary key constraint exists on a table?
Date: 2006-10-13 04:47:27
Message-ID: 12iu6ivjiti162f@corp.supernews.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <52EF20B2E3209443BC37736D00C3C1380AD5FEFF(at)EXADV1(dot)host(dot)magwien(dot)gv(dot)at>,
Albe Laurenz <all(at)adv(dot)magwien(dot)gv(dot)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(at)interlog(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-10-13 04:50:34 Re: Postgresql guidelines for version numbering
Previous Message Richard Broersma Jr 2006-10-13 04:35:29 Postgresql guidelines for version numbering