what is mean by transaction in database?
-
what is mean by transaction in database? is "select" command is also included in transaction?
check this out ... [^] Yes, you could make a select statement part of a transaction. There are implications as to whether or not you would want to do such a thing because there may be negative implications depending on how your isolation level is set. Google "isolation level" for more detail. In MS-SQL, you typically explicitly define a transaction something like this: BEGIN TRANSACTION COMMIT (or ROLLBACK)
-
check this out ... [^] Yes, you could make a select statement part of a transaction. There are implications as to whether or not you would want to do such a thing because there may be negative implications depending on how your isolation level is set. Google "isolation level" for more detail. In MS-SQL, you typically explicitly define a transaction something like this: BEGIN TRANSACTION COMMIT (or ROLLBACK)
-
if select command is use as single like select * from employee then it 'll also included in transaction's defination ? how can i roll back this command?
Here is an example: BEGIN TRANSACTION select * from employee ROLLBACK This is syntactilly correct, but logically not very valid. A SELECT statement does not change the database, therefore a commit or rollback really does nothing except end the transaction. The above example should really should never be used, by starting a transaction you could be creating unnecessary locks to be granted. Transactions are typically used to guarantee that ALL updates are made or NO updates are made. For example: (syntax is not 100% accurate, but you should get the idea) BEGIN TRANSACTION try UPDATE table1 set newbalance = newbalance - 100 where ID=ABC INSERT into audittable values (NOW(),'ABC','WITHDRAWL') COMMIT catch ex ROLLBACK end try This example shows that 2 tables are being updated and if they are successful, the transaction is committed, if there is an error then a rollback is performed.