Re: [SQL] A Table's Primary Key Listing

2005-08-22 Thread Alvaro Herrera
On Mon, Aug 22, 2005 at 03:23:29AM -0700, Roger Tannous wrote: > So, D'Arcy's solution, although described as 'unsatisfactory' (ref.: > D'Arcy's message), seem to be the only solution. > > So I noticed I was trying to play the wise man, trying to do things in a > better way, but nothing was found

Re: [SQL] A Table's Primary Key Listing

2005-08-22 Thread Roger Tannous
So, D'Arcy's solution, although described as 'unsatisfactory' (ref.: D'Arcy's message), seem to be the only solution. So I noticed I was trying to play the wise man, trying to do things in a better way, but nothing was found than D'Arcy's query: SELECT pg_namespace.nspname, pg_class.relname,pg_at

Re: [SQL] A Table's Primary Key Listing

2005-08-19 Thread Roger Tannous
OUPS !! Things seem to be stuck now, since the DB version is 7.3.2, so no array_to_string method is available. Does anyone have any idea how to solve that ? Regards, Roger Tannous. --- Roger Tannous <[EMAIL PROTECTED]> wrote: > Hi to all, there was a BIG MISTAKE in my proposition regarding my

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi to all, there was a BIG MISTAKE in my proposition regarding my last post: In fact, after examining the online documentation (Note that I don't have enough experience in postgreSQL !!) I found that select '(' || replace('1 2', " ", ",") || ')'; could not, in any way, be equivalent to: selec

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi, If you put pg_index.indkey in the select statement, you'd notice that it's sometimes 1 ( it's when we have one PK field) and sometimes 1 2 ( for two PK fields), etc. So I tried to use a replace command like the following: (just to add parentheses, replace the space by a comma to use the res

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Tom Lane
"D'Arcy J.M. Cain" writes: > That's a good question. The following query does this in a very > unsatisfactory way. Anyone know what the general solution would be? > ... > ( > pg_index.indkey[0]=pg_attribute.attnum OR > pg_index.indkey[1]=pg_attribute.attnum OR > pg_index.i

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
On Thu, 18 Aug 2005 09:40:57 -0700 (PDT) Roger Tannous <[EMAIL PROTECTED]> wrote: > Thanks for your query :) > > But it only shows the first of the primary keys of tables having multiple > primary keys :) > > This is apparently because of the pg_index.indkey[0] thing, so how can we > manage this

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Yes, I want only field names, not values. Thanks, Roger Tannous. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---(end of broadcast)--- TIP

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Thanks for your query :) But it only shows the first of the primary keys of tables having multiple primary keys :) This is apparently because of the pg_index.indkey[0] thing, so how can we manage this query in order to get all of the keys :) Thanks in advance, Roger Tannous. --- "D'Arcy J.M.

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
On Thu, 18 Aug 2005 07:36:22 -0700 (PDT) Roger Tannous <[EMAIL PROTECTED]> wrote: > Is there any means to get a list of the Primary Keys (or simply the > Primary Key if there's only one :) ) for a given table using an SQL query Here is what I do in PyGreSQL: SELECT pg_namespace.nspname, pg_class.

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread daq
RT> Hi to all, RT> Is there any means to get a list of the Primary Keys (or simply the RT> Primary Key if there's only one :) ) for a given table using an SQL query RT> ? RT> Regards, RT> Roger Tannous. Something like this? select (select attname from pg_attribute where attrelid=pg_index.ind

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Michael Fuhr
On Thu, Aug 18, 2005 at 07:36:22AM -0700, Roger Tannous wrote: > Is there any means to get a list of the Primary Keys (or simply the > Primary Key if there's only one :) ) for a given table using an SQL query? Are you looking for the primary key definition or do you want the primary key values the

[SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi to all, Is there any means to get a list of the Primary Keys (or simply the Primary Key if there's only one :) ) for a given table using an SQL query ? Regards, Roger Tannous. __ Do you Yahoo!? Yahoo! Mail - You care about securi