I am trying to TRUNCATE
and INSERT
data into a MySQL InnoDB table.
I wanted to make sure that if any statement in the transaction failed, the data will be untouched.
I can't have an empty or corrupted table if something fails.
This is how I planned to do it.
BEGIN TRANSACTION
TRUNCATE TABLE table_name
INSERT INTO table_name
COMMIT
I then learned that TRUNCATE TABLE table_name
causes an implicit COMMIT, which makes the whole transcation pointless.
I then replaced the TRUNCATE TABLE table_name
with a DELETE FROM table_name
approach, which wasn't ideal - but that too causes an implicit COMMIT!
DROP TABLE table_name
and CREATE TABLE table_name
also causes an implicit COMMIT!
What method / logic is best to perform what I am trying to do?
Using MySQL 5.6.17 64-bit server running on Windows Server 2008 R2
DELETE
causes implicit commit ?