Monday, 26 December 2011

delete and truncate both can be roll back

                        for delete
                            select * from e11       -run this script

                            id    name          ///record will display
                            2    mukesh
                            3     mks
                    
                    now run  this script one by one
                              
                           step1-run this                    begin tran aa    
                                    
                             step-2     run this                    delete e11
 
                                 now run this script     select * from e11
                                       you will see there is no record

                                       id    name         


                                                                     commit tran aa
                              step 3- run this        rollback tran aa

                    now run this script     select * from e11
                                       you will see there is  record

                             id    name          ///record will display
                            2    mukesh
                            3     mks


but if you commit transaction than no rollback is possible
                                  


            for truncate


                               select * from e11       -run this script

                            id    name          ///record will display
                            2    mukesh
                            3     mks
                    
                    now run  this script one by one
                              
                           step1-run this                    begin tran aa    
                                    
                             step-2     run this                    delete  truncate e11
 
                                 now run this script     select * from e11
                                       you will see there is no record

                                       id    name         


                                                                     commit tran aa
                              step 3- run this        rollback tran aa

                    now run this script     select * from e11
                                       you will see there is  record

                             id    name          ///record will display
                            2    mukesh
                            3     mks


but if you commit transaction than no rollback is possible
                                  

No comments:

Post a Comment