Question

For testing code I'm copying data from a live database to a test database using SQLYog's "Copy to different host" option. Most of the time, this is okay. But for some tables the dataset is absolutely huge and I only need a relatively small subset of the data for testing. The Copy to different host dialog gives you the option of copying structure only or structure and data.

If I only want partial data, I have to run a select * on table where condition query, export the results as an SQL query, import that query into the test host and run it. While this works, it's not exactly a fun procedure, especially given circumstances where even the "small" subset of test data is still a lot of rows. If some of the data was already copied over than that adds further complications, as I have to write a query to get a list of keys on the target and then add a where key not in (key list) condition onto the main condition.

Is there a way to get the "copy to different host" feature to only selectively copy rows to the target database?

Was it helpful?

Solution

It is currently not possible to use a WHERE condition on individual rows in the SQLyog copy tool. As long as only a single table is selected for copy it is OK, but with more tables it won't make sense.

What you can do now is to create a small 'dummy' table on source and copy this one. The workflow could be like:

1) CREATE TABLE newtable AS SELECT * FROM oldtable WHERE ...

2) Now copy newtable using SQLyog GUI and next drop it on source if required

3) RENAME newtable on target if required

This will reduce network traffic to only consider only the rows you want to transfer. And you will avoid exporting to a file as the 'reduction' is kept inside the source server (does not involve file system or network).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top