nguyentt
nguyentt

Reputation: 669

How to insert all data from one schema to another schema by MySQL queries?

I would like to copy all data from one schema (a) to another (b). Two schemas have the same structure.

I use

Insert into a.table1 select * from b.table1;

But there are 254 tables in a and listing them is very frustrated.

Do you have any better solution?

Thanks

Upvotes: 1

Views: 934

Answers (1)

JohnHC
JohnHC

Reputation: 11205

2 options...

1) Use dynamic SQL to loop through the results of:

select TABLE_NAME from information_schema.tables

2) Output the results of that query into excel, build your inserts from that then run them in a big old proc.

Upvotes: 1

Related Questions