I got a pretty large DB-Table that I need to split into smaller tables for different reasons.
The handling happens via php close to this example:
// Note: It's an example and not working code - the actual function is much larger
function split_db()
{
$results = "
SELECT *
FROM big_table
";
foreach ( $results as $result )
{
// Here I split the big_tables contents and ...
$some_val = $result->SomeVal;
// ...
$another_val = $result->AnotherVal;
// ... here I insert the contents in the different tables
$sql = "
INSERT
INTO first_small_table
// ...
VALUES
// ...
";
}
}
Problem: The query inserts 255 rows, no matter if I’m in the local environment or on the test server.
Question: Why? What am I doing wrong or am I missing something? And how would I avoid this?
Info about MySQL-Client-Version:
- Dev-Server: 5.0.32,
- Local Dev-Env.: 5.1.41
I’m no MySQL-Hero, so any help and explanation is appreciated, as Google brought nothing meaningful (to me) up. Thanks!
I bet you have your primary key of
unsigned tinyinttype, that has limit of 255 for the maximum value.So change it to just
int