MySQL Forums
Forum List  »  General

Re: Rename column but keep old name as alias
Posted by: Rick James
Date: December 23, 2015 11:18PM

Once the old name is gone, any queries mentioning it will get an error to the effect of "no such column".

By having two columns, you avoid that. However, my suggested solution may need the addition of a TRIGGER to keep the two columns in sync.

Or you can upgrade to 5.7 or MariaDB 10.1. Both have flavors of "virtual columns", which lets you have a column by another name that does not really exist; it is just an expression that evaluates to the original column.

But, that may not work if it is not writable. So, again, a RENAME may be necessary to swap the names.

Or... How about a VIEW that gives a different name for the column. This might be the best solution.

Options: ReplyQuote


Subject
Written By
Posted
Re: Rename column but keep old name as alias
December 23, 2015 11:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.