Обсуждение: Exclude fields from SELECT command

Поиск
Список
Период
Сортировка

Exclude fields from SELECT command

От
"Charles Tam"
Дата:
<div class="Section1"><p class="MsoNormal">Hi Everybody<p class="MsoNormal"> <p class="MsoNormal">I’ve a table with 35
fieldsand would like to perform a SELECT command without specifying every single field.<p class="MsoNormal">As such,
I’veuse the SELECT * command.  Is there an approach to exclude 5 fields from being returned?<p class="MsoNormal"> <p
class="MsoNormal">Thanksfor your time.<p class="MsoNormal"> <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:Consolas">KindRegards</span><p class="MsoNormal"><span
style="font-size:10.5pt;font-family:Consolas">Charles</span><p class="MsoNormal"> </div> 

Re: Exclude fields from SELECT command

От
Pavel Stehule
Дата:
2009/3/16 Charles Tam <c.tam@osm.net.au>:
> Hi Everybody
>
>
>
> I’ve a table with 35 fields and would like to perform a SELECT command
> without specifying every single field.
>
> As such, I’ve use the SELECT * command.  Is there an approach to exclude 5
> fields from being returned?
>
>
>

hello

no, there are no way

regards
Pavel Stehule

> Thanks for your time.
>
>
>
> Kind Regards
>
> Charles
>
>


Re: Exclude fields from SELECT command

От
Ashish Karalkar
Дата:
Pavel Stehule wrote:
> 2009/3/16 Charles Tam <c.tam@osm.net.au>:
>   
>> Hi Everybody
>>
>>
>>
>> I’ve a table with 35 fields and would like to perform a SELECT command
>> without specifying every single field.
>>
>> As such, I’ve use the SELECT * command.  Is there an approach to exclude 5
>> fields from being returned?
>>
>>
>>
>>     
>
> hello
>
> no, there are no way
>
> regards
> Pavel Stehule
>
>   
>> Thanks for your time.
>>
>>
>>
>> Kind Regards
>>
>> Charles
>>
>>
>>     
>
>   
Workaround is create a view on that table excluding those 5 fields and 
then select * from that view .


With regards
Ashish Karalkar



Re: Exclude fields from SELECT command

От
Pavel Stehule
Дата:
Hello


>>
>>
>
> Workaround is create a view on that table excluding those 5 fields and then
> select * from that view .
>

I know better solution. Use only thin tables. Wide tables are devil. :)

regards
Pavel Stehule

>
> With regards
> Ashish Karalkar
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


Re: Exclude fields from SELECT command

От
sathiya psql
Дата:
In what way it is devil ???? Clarifications. ..<br /><br /><div class="gmail_quote"><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br
/></div>Iknow better solution. Use only thin tables. Wide tables are devil. :)<br /></blockquote></div><br /> 

Re: Exclude fields from SELECT command

От
Steve Midgley
Дата:
At 05:20 PM 3/16/2009, pgsql-sql-owner@postgresql.org wrote:
>In-Reply-To: <1992170861895942422@unknownmsgid>
>References: <1992170861895942422@unknownmsgid>
>Date: Mon, 16 Mar 2009 22:45:54 +0100
>Message-ID:
><162867790903161445i78127316s1c0deb3bec0e15e5@mail.gmail.com>
>Subject: Re: Exclude fields from SELECT command
>From: Pavel Stehule <pavel.stehule@gmail.com>
>To: Charles Tam <c.tam@osm.net.au>
>Cc: pgsql-sql@postgresql.org
>
>2009/3/16 Charles Tam <c.tam@osm.net.au>:
> > Hi Everybody
> >
> >
> >
> > I’ve a table with 35 fields and would like
> to perform a SELECT command
> > without specifying every single field.
> >
> > As such, I’ve use the SELECT *
> command.  Is there an approach to exclude 5
> > fields from being returned?
> >
> >
> >
>
>hello
>
>no, there are no way
>
>regards
>Pavel Stehule

I think Pavel is right for 99% of the cases. But
there is a "cure that is worse than the disease."

You could select all columns from a bunch of
tables without knowing what the column names
were, excepting N columns, by iterating through
the info schema data and building a SQL select
appropriately (sql meta-programming I guess you
would call it). But it's a real chore to do
manually. If you have this need for some
programmatic purpose (where some initial
investment in effort will pay future dividends),
then check out the info schema options:

http://developer.postgresql.org/pgdocs/postgres/infoschema-columns.html

In your case, I think you'd be looking for five
values of "table_name" and then looking at all
the "column_name" fields, building your column
list, excepting the column_names you wish to exclude..

Best,

Steve