identify Tables without primary keys - postgres

Started by akp geekabout 16 years ago2 messagesgeneral
Jump to latest
#1akp geek
akpgeek@gmail.com

Dear all -

I have the following query to find the tables with primary
keys. can you please help me finding the tables without primary key.

select
distinct x.table_name,
from
information_schema.constraint_column_usage x,
pg_constraint b
where
b.contype='p' and
x.constraint_name=b.conname

Regards

#2Rodrigo Gonzalez
rjgonzale@estrads.com.ar
In reply to: akp geek (#1)
Re: identify Tables without primary keys - postgres

Check
http://petereisentraut.blogspot.com/2009/07/how-to-find-all-tables-without-primary.html

Show quoted text

On Fri, 2010-01-15 at 11:39 -0500, akp geek wrote:

Dear all -

I have the following query to find the tables with
primary keys. can you please help me finding the tables without
primary key.

select
distinct x.table_name,
from
information_schema.constraint_column_usage x,
pg_constraint b
where
b.contype='p' and
x.constraint_name=b.conname

Regards