What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 55396 |  Welcome, Guest!   Register  Login
Home > Articles > Sql Server > DataBase Transaction

DataBase Transaction

Article posted by Syedshakeer on 2/18/2009 | Views: 2658 | Category: Sql Server | Level: Beginner red flag


DataBase Transaction

Introduction
Introduction goes here
DataBase Transaction?

 

A transaction begind when the first DML statement is encountered and ends when one of the following occurs:

 

  1. A COMMIT or ROLLBACK statement is issued
  2. A DDL statement such a CREATE is issued
  3. A DCL statement is issued

 

There are two Types of Transaction Control Statements:

 

  1. Explicit Transaction Control Statements
  2. Implicit Transaction Control Statements

 

Explicit Transaction Control Statements :

 

 You can Control the logic of transactions by using the COMMIT,SAVEPOINT and ROLLBACK statements.

 

COMMIT:       

 

Satae of the Date after COMMIT:

 Ends the current transaction by making all Pending data changes Permanent.

 

a)    The previous state of the data is permanently lost

b)    All users can view the results of the transaction

c)     The locks on the eaffected rows are released

d)    All save Points are erased

 

Example:

  Delete from emp where empid=101;

     1 row deleted.

 

  Insert into emp values(101,’smile’);

     1 row inserted.

 

   Commit the changes:

 

   Commit;

    Commit Complete.

 

 

SAVEPOINT:

Marks a savepoint within the current transaction.

 

ROLLBACK:

 

a)    It ends the current transaction by discarding all pending data changes

b)    Previous state of the data is restored.

c)     Locks on the affected rows are released.

 

Example:

Delete from emp;

10 rows deleted.

 

ROLLBACK;

Rollback Complete.

 

Delete from emp where empid=101;

1 row deleted.

 

 

Implicit Transaction Control:

 

  An automatic commit occurs under the following circumstances:

 

a)    DDL statement is issued.(Create ,Alter,Drop,Rename,Truncate)

b)    DCL statement is issued.(Grant and Revoke)

c)     Normal exit without issuing COMMIT or ROLLBACK Statements

 

  An automatic Rollback occurs under an abnormal termination.




 

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:2 year(s)
Home page:http://www.dotnetfunda.com
Member since:Thursday, February 05, 2009
Level:Starter
Status: [Member]
Biography:Shakeer Hussain has completed his Master of Computer Applications degree from Deccan College of engg and technology of Osmania University.He is a MVM of www.dotnetspider.com.He has good experience in the areas of ASP.NET, C#.NET, VB.NET, SQL SERVER 2000/2005 and Windows Mobile. He has worked in Windows Mobile,Web Applicatin and ERP projects.
>> Write Response - Respond to this post and get points
Related Posts

Most of us worry about Database Backup is Time taken, free space required for the backup file etc. etc.

This is part 22 of the series of article on SSIS. In this article we are going to see how to receive file from FTP task in SSIS.

Hi, In my earlier post I gave some tips to improve sql performace and some tips to improve database quality. This post is a next step in which I gave some excellent tips which will help you to avoid or atleast minimize the database surprises which we called as 'Exceptions'.

This is part 10 of the series of article on SSIS

This article explores differences in the features (of SQL server 2008 and higher) of providing tracking and auditing abilities i.e. the change tracking (CT) and data capture (CDC) abilities.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 9:56:03 AM