Search Postgresql Archives

Re: all non-PK columns from information schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 15 Nov 2011 09:26:35 -0600
Mike Blackwell <mike.blackwell@xxxxxxx> wrote:

>On Tue, Nov 15, 2011 at 02:59, Tarlika Elisabeth Schmitz <
>postgresql6@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> I'd  like to select all column names for a specific table except
>> those that are part of the PK.
>> --
>> Tarlika Elisabeth Schmitz
>>
>I'd probably use the system catalogs.  See
>http://www.postgresql.org/docs/9.1/interactive/catalogs.html
>
>You could do something along the lines of:
>
>select attname from pg_class t
>join pg_attribute on (attrelid = t.oid)
>where attnum > 0
>and not exists (select 1 from pg_constraint where conrelid = t.oid and
>attnum = any(conkey) and contype = 'p')
>and relname = 'table_of_interest'
>__________________________________________________________________________________
>*Mike Blackwell | Technical Analyst, Distribution Services/Rollout

Thanks for the reply, Mike.
Interesting. I have previously used the information_schema for similar
queries.

What are the pros and cons for using either pg_catalog or
information_schema?

-- 

Best Regards,
Tarlika Elisabeth Schmitz

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux