Re: [SQL] How to know column constraints via system catalog tables

2003-11-13 Thread Christoph Haller
> > The only issue I find with your SQL is it relies on "(a.attnum = x.conkey[1] or > a.attnum = x.conkey[2])" which assumes there is two columns forming the primary key of a table. Perhaps, I should explain what I'm trying to achieve with this SQL. > Not exactly. Look at this CREATE TABLE fil

Re: [SQL] How to know column constraints via system catalog tables

2003-11-12 Thread Damon Chong
Thanks alot, you are right with the table and the -E option. It's very useful. The only issue I find with your SQL is it relies on "(a.attnum = x.conkey[1] or a.attnum = x.conkey[2])" which assumes there is two columns forming the primary key of a table. Perhaps, I should explain what I'm tryi

Re: [SQL] How to know column constraints via system catalog tables

2003-11-11 Thread Christoph Haller
> > Thanks for the reply but my main problem is I'm trying to find the primary column(s) > and the data type of these column in a table. pg_constraint's conkey is a int2[] > field. So if i have a table called 'films' (taken from postgreSQL doc) that has two > primary keys (composite primary key

Re: [SQL] How to know column constraints via system catalog tables

2003-11-11 Thread Christoph Haller
> > Hi, > > I need to query each column's constraint and name of a table in > postgreSQL v7.3.4 with a single SQL query but don't know how. Would > appreciate any pointers! > > Thank you. > > Regards, > Damon > select relname,conname from pg_constraint,pg_class where pg_class.oid=conrelid ;

[SQL] How to know column constraints via system catalog tables

2003-11-08 Thread Damon
Hi, I need to query each column's constraint and name of a table in postgreSQL v7.3.4 with a single SQL query but don't know how. Would appreciate any pointers! Thank you. Regards, Damon ---(end of broadcast)--- TIP 8: explain analyze is your frie