Re: PostgreSQL Inheritance and column mapping

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL Inheritance and column mapping
Date: 2014-10-03 02:54:22
Message-ID: 542E0FDE.5020703@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/2/14, 9:00 AM, Tom Lane wrote:
> Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> writes:
>> Was there ever any discussion.thought about being able to follow a non-strict by name
>> column mapping between inherited tables and father tables?
> No. You could use a view with UNION ALL perhaps.
FWIW, I've had some less than stellar results with that (admittedly, back on 8.4).

The other thing you could do is something like:

ALTER TABLE invoice_document RENAME TO invoice_document_raw;
ALTER TABLE invoice_document_raw RENAME invoice_no TO doc_no;
CREATE VIEW invoice_document AS
SELECT ...
, doc_no AS invoice_no
, ...
FROM invoice_document_raw
;

If you make that view writable then no one needs to know that you renamed the column in the underlying table.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-10-03 03:04:21 Re: How to find greatest record before known values fast
Previous Message Jim Nasby 2014-10-03 02:44:38 Re: How to find greatest record before known values fast