Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mysql copy entire column to a new one

Posted on 2016-09-23
3
Medium Priority
?
69 Views
Last Modified: 2016-09-23
what is the sql sentence to copy a column to the a new coloumn?
I want to create a copy of a column
0
Comment
Question by:Braveheartli
  • 2
3 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 41812509
>>what is the sql sentence to copy a column to the a new coloumn?
>>I want to create a copy of a column

ceate a new column first and then use an update query.
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 41812514
for example:
ALTER TABLE yourTable ADD newCol VARCHAR(250);

Open in new window

then:
Update yourTable Set newCol = oldCol;

Open in new window

0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41812618
thank you
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question