Re: selecting all columns but one

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: blackwater dev <blackwaterdev(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: selecting all columns but one
Date: 2009-07-28 13:24:52
Message-ID: b42b73150907280624g35bc46caidc89924d612377f0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jul 28, 2009 at 9:12 AM, blackwater dev<blackwaterdev(at)gmail(dot)com> wrote:
> I have a table with a lot of columns.  One of the columns I want to alias so
> have a query of:
> select *, column as newname from mytable.
> The problem is I now have column and newname in the results.  I don't want
> to select column by column.  How can I do a select * but omit one?
> Thanks!

there is no easy way. the only way I can think of is to build the
query with dynamic sql (either in pl/pgsql or the client), and query
the system catalogs so you can build the column list filtering out the
column you don't want.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2009-07-28 13:25:02 Re: selecting all columns but one
Previous Message Robert James 2009-07-28 13:22:53 Re: Clients disconnect but query still runs