Skip site navigation (1) Skip section navigation (2)

Re: select as

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Bambero <bambero(at)tlen(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select as
Date: 2004-12-23 18:20:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Thu, Dec 23, 2004 at 06:37:14PM +0000, Bambero wrote:

> Is there any easy way to select all fields from table (*) but the result 
> should looks like this:
>   1|    2|    3
> ----+-----+------
> asas| asd | dasd
> ada | ads | dasa
> Column name should be a number of column.

Why do you need to do this?  Anyway, if you're making queries with
an interface that can fetch rows as an array, then you could display
column numbers based on their position in the array.

> I don't know what fields are in the table so:
> select fieldname as 1, fieldname2 as 2
> is useless.

What problem are you trying to solve?  Why are you querying a table
when you don't know what fields it has?  Are you building a generic
interface for querying any table?  If so, then you can get column
positions and types by examining the system catalogs.  See the
"System Catalogs" and "The Information Schema" chapters in the
PostgreSQL documentation (Information Schema is available in 7.4
and later).

Michael Fuhr

In response to

  • select as at 2004-12-23 18:37:14 from Bambero

pgsql-general by date

Next:From: BamberoDate: 2004-12-23 18:37:14
Subject: select as
Previous:From: Lonni J FriedmanDate: 2004-12-23 18:03:12
Subject: Re: monitoring tools

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group