Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 29880 |  Welcome, Guest!   Register  Login
Home > Articles > Sql Server > DataBase Transaction

DataBase Transaction

Article posted by Syedshakeer on 2/18/2009 | Views: 2212 | 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

This article explains how we can generate scripts using SQL Server

This is part 26 of the series of article on SSIS. In this article we are going to learn how to delete remote FTP folder in SSIS.

This is part 30 of the series of article on SSIS and in this article we are going to see what is Data Flow Transformations in SSIS and the list of controls that are provided in the data flow transformations followed by the series on each of the control and the usage of the controls.

This article explains the TOP with TIES clause.

While loading data into a table I am disabling all the integrity constraints and after once I finished loading I am enabling all of them. Now the problem is some data which is not at all valid(Referred data not exists in parent table). How can I perform the integrity check on the loaded data and remove the unwanted same ?

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 found 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/28/2012 11:57:20 AM