Created
February 27, 2019 15:01
-
-
Save stefpe/645775bbc4a86a779627632121c65a6f to your computer and use it in GitHub Desktop.
Simple script to copy by id from one to another db table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$con = mysqli_connect("host","user", "password"); | |
mysqli_select_db($con, "dbname"); | |
$stepSize = 100000; | |
foreach(range(1,50000000, $stepSize) as $step){ | |
$sql = sprintf('insert into tmp_table select * from table where id >= %d and id < %d', $step, $step + $stepSize); | |
mysqli_query($con, $sql); | |
echo $sql .PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment