Transactional Statements
Explore how transactional statements enable control over data changes in MySQL. Understand the ACID properties ensuring database consistency and learn to use START TRANSACTION, COMMIT, and ROLLBACK to verify changes before committing or rolling back for safer data manipulation.
We'll cover the following...
In our running example, we mostly worked with SQL SELECT statements. That is, with queries that read data from the database without modifying it. Though, this is certainly possible with SQL using clauses like INSERT INTO, UPDATE, and DELETE. In our running example of car model parts, we could find ourselves updating the built_at attribute of newly assembled parts:
While the above SQL statement correctly updates built_at for the previously missing car parts, the ones already assembled have also been updated by accident. Without our memory, we would need to rely on external documentation or backups of the database to recover from this mistake. Although artificial, this example ...