database atomicity consistency

后端 未结 3 403
执念已碎
执念已碎 2021-01-01 16:23

What is difference between Atomicity and consistency ? it looks to me as both are saying same thing in different word.

Atomicity

All tasks of a transaction are

3条回答
  •  情歌与酒
    2021-01-01 17:05

    Atomicity :
    Bunch of statement just take an example of 100 statements which can be insert statement also , if any of the statement failed while processing should revert back remaining statement , which means database should go back original state.

    Blockquote

    autocommit = false

    try{
       statement one ;
       statement two ;
        `enter code here`
        `enter code here`
        `enter code here`
       statement three;
      }
       catch (){rollback;}
      finally(){commit;} t
    

    Consistency : If your trying to insert date into database which need to be satisfy the constraints, cascades, triggers like while your trying to insert the data into database but the table has primary key constraints so the data your planning to insert should be satisfy with primary key constraint.

    Isolation : if two process are running on database assume one is reading and other is writing the data into database . the reading thread should read only committed data , should not be in-memory data

    Durability : once transaction data committed into the database should be same stage , it should not affect the from power failure or system crash any other

提交回复
热议问题