Quickly add a copy of a column to a MySQL table
mysql, sql
Solution
The obvious solution is the only solution, unfortunately.
However note that in general you shouldn't be copying a column in relational databases.
Problem
I need a fast way duplicate a DATETIME column in a table and give it a new name. I have a column named myDate in my table called myResults, I need a query to make a new column in the table called newDate which has the exact same data as the myDate column. Is there a faster way to do this than by doing the obvious 2 step approach of make a new column, and then copying all the data (it's a large table and I'm looking for the fastest approach)? Obvious solution: ``` ALTER TABLE `myResults` ADD `newDate` DATETIME; UPDATE `myResults` SET `newDate` = `myDate`; ```