Re: psql UPDATE field [tab] expands to DEFAULT?

Поиск
Список
Период
Сортировка
От Ken Tanzer
Тема Re: psql UPDATE field [tab] expands to DEFAULT?
Дата
Msg-id CAD3a31XEaeB2odBznuwv3xfshSAzUMPc1yEzGbZezRfQf-+hCA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: psql UPDATE field [tab] expands to DEFAULT?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: psql UPDATE field [tab] expands to DEFAULT?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On Mon, Jun 17, 2019 at 4:24 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:

My cheat for dealing with many/long column names is:

test=# \d up_test
               Table "public.up_test"
  Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
  id     | integer |           |          |
  col1   | boolean |           |          |
  col2   | integer |           |          |



test=# \pset format unaligned
Output format is unaligned.
test=# \pset fieldsep ','
Field separator is ",".

select * from up_test limit 0;
id,col1,col2

Cut and paste above.

test=# \pset fieldsep '|'
Field separator is "|".

test=# \pset format 'aligned'
Output format is aligned.


Just curious, but if you really do that often, wouldn't you be better off with something like this?

CREATE OR REPLACE FUNCTION field_list( name ) RETURNS text AS $$

SELECT array_to_string(array_agg(column_name::text ORDER BY ordinal_position),',') FROM information_schema.columns WHERE table_name = $1;

$$ LANGUAGE sql STABLE;


Cheers,
Ken



--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: delete inside for plpgsql loop on same relation?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: psql UPDATE field [tab] expands to DEFAULT?