Is a sequence of operations performed as a single logical unit of work or transaction logical unit of work.
-> Begin transaction
-> commit transaction
-> rollback transaction
crate table accounts
insert into accounts values(1,'sravanthi',20000);
insert into accounts values(2,'mamatha',5000);
select* from accounts
Properties of Transactions :
Every logical unit of work must exhibit four properties to consider that as a transaction.Those properties are called as ACID properties.
Atomicity: Consider a transaction having n number of queries either all these n number of queries has to be successfully completed or all n number of queries should fail.This type of property is called as atomicity.
Consistency: After completion of a transaction all the data should be left in a consistent state. That means when you insert a new record in a table called students and
for example if the table is having any associated indexes, after inserting the data into the table the associated indexes should be updated appropriately.
Isolation: As per isolation no two concurrent transaction should be allowed to act upon a single data.
Durability: After completion of a transaction the data modified by the transaction should be stored permanently in the DB even in case of system failure.
Query: Stored procedure to transfer amount and deduct.
create proc transfermoney,
@sacid int,@dacid int,@amount int
update accounts st balance=balance-@amount where acid =@sacid,
update accounts set balance =balance-@amount where acid =@acid,