Thursday, June 1, 2017

[Solved] Oracle: Copy a column into another column within the same table

If for some reason you want to add a new column and copy the data from an old column into the new column instead of resetting the column name or data type of the old column, you can do it by executing a sql statement.

A. Copy all the values from an old column into a new column.

Update tableName set oldColumn = newColumn;

B. Copy all the values from several old columns into several new columns

Update tableName set oldColumn1 = newColumn1, oldColumn2 = new column2, oldColumn3 = newColumn3 . . . . . . ;

C. Copy only these row having a specific value in a column;

Update tableName set oldColumn = newColumn where specificColumn  = aValue;

The specificColumn can be the oldColumn itself.

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment