Previous |
Next |
Distributed SQL enables applications and users to query or modify information in multiple databases with a single SQL statement. Because distributed SQL masks the physical location of your data, you can change the location of your data without changing your application. Distributed SQL includes the following: distributed queries (which access data) and distributed transactions (which modify data). In distributed transactions, the two-phase commit mechanism guarantees the integrity of your data by ensuring that all statements in a transaction either commit or roll back as a unit at each database involved in the distributed transaction.
When an application or user tries to commit a distributed transaction, the database to which the application or user is connected is called the global coordinator. The global coordinator completes the two-phase commit by initiating the following phases:
Prepare Phase: The global coordinator asks the other databases involved in the distributed transaction to confirm that they can either commit or roll back the transaction, even if there is a failure. If any database cannot complete the prepare phase, then the transaction is rolled back.
Commit Phase: If all of the other databases inform the global coordinator that they are prepared, then the global coordinator commits the transaction and asks all of the other databases to commit the transaction.