MilesWeb
MilesWeb Hosting Forum

Please login or register.

Login with username, password and session length

 

News:

SMF - Just Installed!


Author Topic: How to copy content of one table to another table ?  (Read 3371 times)

0 Members and 1 Guest are viewing this topic.

Offline Dipak Bhoi

  • MilesWeb Team Member
  • Full Member
  • ***
  • Posts: 208
  • Karma: +5/-0
    • View Profile
    • MilesWeb Internet Services
How to copy content of one table to another table ?
« on: June 19, 2015, 03:22:52 PM »
Hello folks,

I found a new and simple way to copy content of one table to another table within same database using command prompt. You can copy/duplicate one table to new table at the time to creating new table.

Go to mysql prompt and switch to the database in which you wish to copy/duplicate table.

Quote
mysql> use database_name;

mysql> CREATE TABLE new_table_name SELECT * FROM old_table_name;
Above CREATE TABLE command will create a new_table_name' like table 'old_table_name' and entire data from old table will be copied to new table. You can break this operation into two steps as well. Let see below two command which will perform same operation.

Quote
mysql>CREATE TABLE new_table_name LIKE old_table_name;

Quote
myslq>INSERT INTO new_table_name SELECT * FROM `old_table_name`;

Using above commands you can create new table like old table and then copy entire data of old table into new table.

Hope this post will help..

That's all....... Enjoy !!  :);) :)

MilesWeb.com
cPanel Hosting in India - cPanel Hosting in India.

Grab an SSL for your website and SAVE 20% now. Coupon Code SSLSAVE20.

MilesWeb Hosting Forum

How to copy content of one table to another table ?
« on: June 19, 2015, 03:22:52 PM »