1 导读
数据的一致性是数据精确的重要指标,那如何实现数据的一致性呢?本文从事务个性和事务级别的角度和大家一起学习如何实现数据的读写一致性。
2 一致性
1. 数据的一致性:通常指关联数据之间的逻辑关系是否正确和残缺。
举个例子:某零碎实现读写拆散,读数据库是写数据库的备份库,小李在零碎中之前录入的学历信息是高中,通过小李努力学习,胜利取得了本科学位。小李及时把信息变成成了本科,可是因为明天零碎备份工夫较长,小李变更信息时,数据曾经开始备份。公司的 HR 通过零碎查问小李信息时,发现还是本科,小李的申请被驳回。这就是数据不统一问题。
2. 数据库的一致性:是指数据库从一个一致性状态变到另一个一致性状态。这是事务的一致性的定义。
举个例子:仓库中商品 A 有 100 件,门店中商品 A 有 10 件。上午 10 点,仓库发送商品 A50 件到门店,最初仓库中有商品 A50 件,门店有商品 A60 件,这样商品的总是是不变的。不能门店收到货后,仓库的商品 A 还是 100 件,这样就呈现数据库不统一问题。仓库和门店商品 A 的总数是 110 才是正确的,这就是数据库的一致性。
3 数据库事务
数据库事务 (transaction) 是拜访并可能操作各种数据项的一个数据库操作序列,这些操作要么全副执行, 要么全副不执行,是一个不可分割的工作单位。事务由事务开始与事务完结之间执行的全副数据库操作组成。
事务的性质:
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…
https://weibo.com/a/hot/76279…