Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How To Move 1 million Records from One table to Another Table?

user-image
Question added by Jettiboyina Rajesh , Java Developer , XML FRAMEWORKS COM PVT LTD
Date Posted: 2017/04/24
Ibraheem Umar
by Ibraheem Umar , Technical Consultant , DXC technology Pvt Ltd

One way is :

using  SELECT INTO OUTFILE to put data in test.csv file :

SELECT * INTO OUTFILE 'test.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\\n' FROM <table name>

Then Insert to new table :

LOAD DATA INFILE 'test.csv' INTO TABLE <tablename> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\\n' (column1,column2,column3)

 

Ghazanfar Shafiq
by Ghazanfar Shafiq , Project Supervisor , A Tayebat Hyper Market

1. Use Import or export method

 

OR

2. Create table with same structure(design). Let say new table name is "table2" and first one from where you want to transfer is "table1".  then use this query

 

insert into table2 select *from table1

 

Use this query

amar husain
by amar husain , Lead full stack developer , Saudi Aramco

alter table mytable add (newcolumn date); update mytable set newcolumn = oldcolumn; alter table mytable drop (oldcolumn);It's usually faster to disable the keys first, do the inserts, then enable the keys after insertion.

Uday Amineni
by Uday Amineni , Process Associate , [24]7

By using a VIEW we can move the data from ne table to another table that is data migration

Azam Mirzobekov
by Azam Mirzobekov , Waiter , Louvre Museum Restaurant

INSERT INTO `db`.`table_to`

SELECT *

FROM `db`.`table_from` ;

subhojit chaudhury
by subhojit chaudhury , TIER 2 ENGINEER , ACONEX INDIA PVT. LTD.

Create table with same structure(design). Let say new table name is "table2" and first one from where you want to transfer is "table1".  then use this query

 

 

 

insert into table2 select *from table1

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.