Context
Let's say I have a field called A
of type CHAR
and a field called B
of type INT
.
I'm migrating field A
to a new type by creating a new field and copying the values around. The field is called B
.
At the moment the two field coexist while I am copying the data from a column to another and the application code has a fallback so if column B contains a value then return B, otherwise return the value from A and convert the value at the application level.
The Problem
Now I would like to rename B
to A
but I'm finding it really difficult to find a solution that doesn't require many deploys by creating another temp column and doing a switch of columns again.
Questions
Is there anyway where I can say something like select (int(A) or B) as B from table
?
Or do you have any ideas on making this a little bit smoother?
Best Answer
No you caqn't have two columns with the same name.
What you can do is
db<>fiddle here