Re: partial JOIN (was: ID column naming convention) - Mailing list pgsql-general

From Jim Nasby
Subject Re: partial JOIN (was: ID column naming convention)
Date
Msg-id 562D788F.4000001@BlueTreble.com
Whole thread Raw
In response to Re: partial JOIN (was: ID column naming convention)  (Rafal Pietrak <rafal@ztk-rp.eu>)
Responses Re: partial JOIN (was: ID column naming convention)  (Rafal Pietrak <rafal@ztk-rp.eu>)
List 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 by date:

Previous
From: Bill Moran
Date:
Subject: I'm starting a PostgreSQL user's group in Pittsburgh
Next
From: Jim Nasby
Date:
Subject: Re: Duplicate rows during pg_dump