Re: [SQL] About primary keys -- made some progress

2003-08-16 Thread Tom Lane
Tim Andersen <[EMAIL PROTECTED]> writes: > I still have a question about how to get the > information about length and precision of a column > from pg_attributes.atttypmod. are there built-in > functions for PostgreSQL to extract this information? Best is to rely on the format_type() function. A

Re: [SQL] About primary keys -- made some progress

2003-08-15 Thread Tim Andersen
This might not be the cleanest solution, but it runs fast and it retrieved the information I need. I broke it down into pieces and created several views to query from to simplify it for myself. The first four statements are views and the last one is the query I was originally trying to get. (note

Re: [SQL] About primary keys.

2003-08-15 Thread Tim Andersen
I looked in the info.c on line 2891 of the psqlodbc-7.2.5 to find this SQL logic (courtesy of Tom Lane) select ta.attname, ia.attnum from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i, pg_namespace n where c.oid = i.indrelid AND n.oid = c.relnamespace AND i.indisprimary = 't' AND ia

Re: [SQL] About primary keys.

2003-08-15 Thread Tom Lane
Tim Andersen <[EMAIL PROTECTED]> writes: > The query I have so far only gets columns that are > part of a primary key. >... >and pga1.attnum = i.indkey[pga2.attnum-1]; This is wrong because you are looking at only one indkey position, and the attribute could be in any position of t

Re: [SQL] About primary keys.

2003-08-15 Thread Tim Andersen
I'm new to PostgreSQL but I am familiar with DB2, Oracle and Sybase. I must say, I am impressed with PostgreSQL so far! In order to compare databases across DBMS platforms, we need to create a view that queries from the system catalog tables. This view returns all of the columns in the database

Re: [SQL] About primary keys.

2001-06-19 Thread Roberto Mello
On Tue, Jun 19, 2001 at 02:10:16PM +0200, David BOURIAUD wrote: > Hi the list ! > Is there a way to get in system tables all the primary keys of a table ? There's a recipe that is related to that in my Postgres CookBook that you could adapt to your needs: http://www.brasileiro.net/postgr