I have a table I just made to import a file from Excel.
I call this table test and it’s a duplicate of a real table I have earlier.
Now everything looks fine and I would like to move all my data from TEST into the REAL_TABLE
But how should I do this. I don’t want the auto_increment id’s to be copied (or will they automatically update when I export TEST and then import it to REAL_TABLE?)
Or is there any other solution on how to move all data?
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all, columns, except, autoincrement )
SELECT all, columns, except, autoincrement FROM test' at line 1
another scenario is: even if the real table is empty, copying over the test table using the dreaded, evil “select star” will result in the same auto_increments being kept – and sometimes it is desirable to “renumber” them starting at 1
summary: my suggestion works correctly in all cases, your suggestion works correctly only sometimes
regardless of any reply, I would have no way of verifying if it was true or not and I don’t always just blindly accept what I read in environments like this.
regarding “might”: might, coulda, shoulda etc all lead to speculation.
Posted by Moi
the op didn’t specify if the table had previous rows in it or not.
if the table is always going to be empty (as it is in a lot of my use cases) just before the insert then what I posted is totally valid.
if the table is not empty before the insert then the auto increment should not be copied over.