Chapter 6 PROGRAMMING SQL SERVER 2000 365
Wednesday, September 16th, 2009Chapter 6 PROGRAMMING SQL SERVER 2000 365 Atomicity. A transaction cannot be broken up into smaller units; either the entire transaction happens or none of it happens. Consistency. A completed transaction leaves the database in a consistent state. Isolation. A transaction is isolated from other transactions in the database, so transactions can t overwrite each other s data. Transactions, in other words, can t interfere with other transactions that are running concurrently. Durability. A transaction, after it has been applied, sticks in the database. These qualities are easy to recall by remembering the word ACID : Atomicity, Consistency, Isolation, and Durability. SQL Server provides the atomicity, isolation, and durability for you, but it s up to you to make sure that a transaction leaves the database in a consistent state. Atomicity and durability are handled by the transaction logging system and, to an extent, by the lazy writer, which was covered back in Chapter 2, Data Modeling. Isolation is handled by the lock manager, which is covered in this chapter. Designing and Managing Transactions . Design and manage transactions. If you don t explicitly tell SQL Server to treat a group of statements as a transaction, it implicitly puts each statement in its own transaction. For the purposes of an implicit transaction, the only statements that really count are the statements that interact with a database: SELECT, INSERT, UPDATE, and DELETE. To explicitly put a group of statements into a transaction, you can use the BEGIN TRANSACTION command. This command tells SQL Server all commands that follow up until the end of the transaction, which is noted with an COMMIT TRANSACTION. In the event of a problem with the data being manipulated, you can also call ROLLBACK TRANSACTION. If there is an error during the execution of the transaction, such as a server shutdown, a disk error of some type, or lock contention, then the transaction automatically rolls back.
For high quality java hosting services please check java web hosting website.