Re: partial JOIN (was: ID column naming convention)

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: partial JOIN (was: ID column naming convention)
Дата
Msg-id 562D788F.4000001@BlueTreble.com
обсуждение исходный текст
Ответ на Re: partial JOIN (was: ID column naming convention)  (Rafal Pietrak <rafal@ztk-rp.eu>)
Ответы Re: partial JOIN (was: ID column naming convention)  (Rafal Pietrak <rafal@ztk-rp.eu>)
Список pgsql-general
On 10/25/15 2:30 AM, Rafal Pietrak wrote:
> So personally, I don't see a star in a select list so harmfull, quite
> the oposit.

Using * outside the database is generally very dangerous. Using it
*inside* the database can be very useful, because frequently it's
exactly what you want (give me all the columns, dammit!). In particular,
I find it useful in views where I want the original data, along with
some calculated or other values. For example,

SELECT nspname, c.oid, * FROM pg_class c LEFT JOIN pg_namespace ON...

But there's also times I've wanted a way to manipulate what * would
normally do. In particular, *_except_for(field_list), and *_replace(
regexp_replace to run on each field name). If those existed (and maybe a
way to combine them), it wouldn't be terribly hard for you do handle
your sled query with something like:

SELECT s.*, l.*( s/.*/left_%/ ), r.*( s/.*/right_& )
   FROM sled s JOIN runner l ON ... JOIN runner r ON ...
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com


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

Предыдущее
От: Bill Moran
Дата:
Сообщение: I'm starting a PostgreSQL user's group in Pittsburgh
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: Duplicate rows during pg_dump