Search Postgresql Archives

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

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

 



In article <52EF20B2E3209443BC37736D00C3C1380AD5FEFF@xxxxxxxxxxxxxxxxxxxxxxxxx>,
Albe Laurenz <all@xxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx


[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