Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. what is mean by transaction in database?

what is mean by transaction in database?

Scheduled Pinned Locked Moved Database
questiondatabase
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ali_100
    wrote on last edited by
    #1

    what is mean by transaction in database? is "select" command is also included in transaction?

    D 1 Reply Last reply
    0
    • A Ali_100

      what is mean by transaction in database? is "select" command is also included in transaction?

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      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)

      A 1 Reply Last reply
      0
      • D David Mujica

        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)

        A Offline
        A Offline
        Ali_100
        wrote on last edited by
        #3

        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?

        D 1 Reply Last reply
        0
        • A Ali_100

          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?

          D Offline
          D Offline
          David Mujica
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups