I have a mysql table with the a column name of count
that I need to rename. It was a bad choice for a column name in the early stages of the development. However, simply renaming has huge regression issues - several older versions of the app will still be referencing count
, so I can't just simply or easily change the column name to something else.
Is there any method or technique I can use that will allow me to permanently alias the that column to something else? So eventually when the older app versions phase out we can then just drop the original name and make the alias the permanent name.
If an alias won't work or isn't possible, can someone suggest another idea? We really need to move the column away from being called count
Looking for something like:
// I don't think anything like this exists
alter table tableName change column count set alias countAlias ;
ORIG: SELECT * FROM tableName WHERE count=?
NEW: SELECT * FROM tableName WHERE countAlias=?
But where count
and countAlias
are the same column, so the query would work the same.
Sample Table:
create table user_data(user_id int, cDate date, count int);
mysql> select * from user_data;
+---------+--------+--------+
| user_id | cDate | count |
+---------+--------+--------+
count
is annoying because it needs to be quoted every time but it's a valid name anyway.