Can column name aliases be supported? - Mailing list pgsql-general

From Gauthier, Dave
Subject Can column name aliases be supported?
Date
Msg-id 0AD01C53605506449BA127FB8B99E5E11802BC13@FMSMSX105.amr.corp.intel.com
Whole thread Raw
Responses Re: Can column name aliases be supported?  (Bosco Rama <postgres@boscorama.com>)
Re: Can column name aliases be supported?  (Rob Sargent <robjsargent@gmail.com>)
Re: Can column name aliases be supported?  (Chris Angelico <rosuav@gmail.com>)
List pgsql-general

Here's the problem....

 

I have a table with a column called "last_name".  I have one customer who likes to articulate queries and updates for this using column name "last_name" (no problem there) but another who likes to call it "lname" and yet another who likes to call it "surname".    So 3 different names for the same physical column in the table.

 

I know a view can be used to alias one of them. But what about the other 2?  Three views (or 2 views and the main table) is awkward.  Also, you can't modify the data through a view.

 

I thought of having a table with the 3 column names in there "last_name", "lname" and "surname".  The queries should work fine.  As for the updates and inserts,  have a before trigger make sure they're all synched up.  But that only works if only one of the value changes, otherwise how do you know which one to sync up to! Hmmmm.....

 

Does anyone know of an elegant way to do this? 

 

Thanks in Advance

pgsql-general by date:

Previous
From: Alan Hodgson
Date:
Subject: Re: Migrating from 8.3 to 9.1 - date/time storage types do not match
Next
From: Bosco Rama
Date:
Subject: Re: Can column name aliases be supported?