Re: SELECT from mytbl;

Поиск
Список
Период
Сортировка
От Rodrigo De León
Тема Re: SELECT from mytbl;
Дата
Msg-id 1180483885.536572.84550@q69g2000hsb.googlegroups.com
обсуждение исходный текст
Ответ на SELECT from mytbl;  (brsaweda@gmail.com)
Ответы Re: SELECT from mytbl;  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: SELECT from mytbl;  (Erwin Brandstetter <brsaweda@gmail.com>)
Re: SELECT from mytbl;  (Erwin Brandstetter <brsaweda@gmail.com>)
Список pgsql-general
On May 29, 5:42 pm, brsaw...@gmail.com wrote:
> Hi!
>
> Title says it pretty much. I am wondering if there is a short way to
> form a query that retrieves all fields of a table (of which I do not
> know names and number beforehand) except for one (or more, of which I
> know the name(s)). I have stumbled across the need for this a couple
> of time during the last few years. Maybe there is a way and I am just
> being blind ..
>
> For instance, I would use this in a plpgsql function to select all
> fields but "bad_field" from a number of tables. I know the name of the
> field I DO NOT want, but number and names of the other fields (which I
> want) are not known at the time of writing the function.
>
> Thanx for your hints and please cc answers to my email.
>
> Regards
> Erwin

create table my_t (
    good_field1 int
    , good_field2 int
    , bad_field int
);

select column_name
from information_schema.columns
where table_name = 'my_t';

 column_name
-------------
 good_field1
 good_field2
 bad_field

select column_name
from information_schema.columns
where table_name = 'my_t'
and column_name <> 'bad_field';

 column_name
-------------
 good_field1
 good_field2

-------------------------------

Now see:

http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING


В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: TimeZone List
Следующее
От: novnov
Дата:
Сообщение: function retuning refcursor, order by ignored?