[GENERAL] Is it possible to have multiple names for a column?

2006-09-14 Thread felix
We have a need to rename some columns, but since we can't update both
the database and the programs instantly, we'd like to temporarily
assign both names to the same column while the updates are in
progress.  Something like this would be super nifty :-)

ALTER TABLE howdy_doody ADD NAME xyzzy TO COLUMN plugh;

I am pretty certain no such SQL command exists.  But is it possible to
do something sneaky to the internal tables so that two names point to
the same columnand everything just works?  Everything meaning updates,
inserts, etc, not further ALTER TABLE and so on.

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman  rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] Is it possible to have multiple names for a column?

2006-09-14 Thread Tom Lane
[EMAIL PROTECTED] writes:
 I am pretty certain no such SQL command exists.  But is it possible to
 do something sneaky to the internal tables so that two names point to
 the same columnand everything just works?

No ... at least not for usefully large values of work.

You might be able to do something involving a view that renames the
column in question, with as-yet-unconverted clients made to reference
the view.  Offhand I'm not convinced that's easier than just fixing the
clients though ...

regards, tom lane

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] Is it possible to have multiple names for a column?

2006-09-14 Thread Scott Marlowe
On Thu, 2006-09-14 at 14:18, [EMAIL PROTECTED] wrote:
 We have a need to rename some columns, but since we can't update both
 the database and the programs instantly, we'd like to temporarily
 assign both names to the same column while the updates are in
 progress.  Something like this would be super nifty :-)
 
 ALTER TABLE howdy_doody ADD NAME xyzzy TO COLUMN plugh;
 
 I am pretty certain no such SQL command exists.  But is it possible to
 do something sneaky to the internal tables so that two names point to
 the same columnand everything just works?  Everything meaning updates,
 inserts, etc, not further ALTER TABLE and so on.

You could create a view, make the two outside names reference the one
inside name, and create a trigger to update based on which one if given
data and throw an error if you try to update both columns at the same
time.

Sounds like a lot of work though.

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [GENERAL] Is it possible to have multiple names for a column?

2006-09-14 Thread Bernhard Weisshuhn
On Thu, Sep 14, 2006 at 12:18:05PM -0700, [EMAIL PROTECTED] wrote:

 We have a need to rename some columns, but since we can't update both
 the database and the programs instantly, we'd like to temporarily
 assign both names to the same column while the updates are in
 progress.  Something like this would be super nifty :-)
 
 ALTER TABLE howdy_doody ADD NAME xyzzy TO COLUMN plugh;

If the clients only read the column, you could just add the new
column and create triggers that copy the value from the other column on
any modification.
Later you drop the old column and the triggers.

Maybe an approch based on rules might work? Dunno, haven't used them yet.

regards,
  bkw

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings