views:

499

answers:

2

I added a constraint to a Postgres table, but when I do "\d tablename" the constraint doesn't show up.

How do I see what the constraints are? I'm sure this is a very basic thing, but I can't find the answer!

EDIT: the constraint does actually exist and work.

EDIT: first response now shows how constraint can be found using information_schema, but this method is not very useful as tablename/column name the constraint relates to is not shown. any ideas how to enable constraint output using \d command?

EDIT: problem seems to have fixed itself after a restart of psql and wasting 2 hours of my life. grrr

A: 

Normally it does show up in \d output. Potential problems I may think of is either old version of postgresql or version mismatch between psql and server. If you want to figure out your constraints by hand, you may want to look into information_schema namespace pg_constraint system table.

Michael Krelin - hacker
Thanks. I'm using psql 8.3.7 but it doesn't show up (standard debian lenny package. I did find it doing a "select * from pg_constraint;"
bugmenot77
If your server is also 8.3.7, then it's weird and there must be more to it. I can see all constraints in 8.3.7.
Michael Krelin - hacker
Could be. I'm new to postgres and just did a vanilla install from debian lenny using apt-get. UPDATE. bizarre. just logged out of psql and back in again and now it works...
bugmenot77
Well, as long as it works ;-)
Michael Krelin - hacker
A: 

OK. I figured out what happened and post to save somebody else from wasting their time: I must have entered the command "\t" at some stage to change formatting to show only tuples. Where's the bashing head against brick wall emoticon when you need it!

bugmenot77