Avatar of MRDELPHI
 asked on

Copy data

Hi All :
I've Delphi application, I would like to copy Data from one mysql table to another mysql table with the same structure. for loop its seems too slow. is there any query to do that

DelphiMySQL ServerSQL

Avatar of undefined
Last Comment

8/22/2022 - Mon

insert into table2 select * from table1;

I suggest you still do it in batches.  For example if you have a numeric primary key:

insert into table2 select * from table1 where primary_key_column between 1 and 5000;

Then just have Delphi call that statement, changing 1 and 5000 to the next batch, and so on.

I am trying to do that but there is an error occurred

error message
when i write the "select a.code, a.qty from master a where a.sn between 2610 and 2630"
its return the correct result. but in the insert statement there is an error

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

//use Create Like:
command := 'CREATE TABLE items2 LIKE items1';
//then insert
command := 'INSERT INTO items2 SELECT * FROM items1';
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.