sql中binary_checksum(*)的用法

sql中binary_checksum(*)的用法(转)

binary_checksum(*)可以用来检查修改过的行。

同一行在update后,该行的binary_checksum(*)就不同。 如

select title_id,binary_checksum(*)  from titles where  title_id=1 时title_id=1 的该行的binaru_checksum(*) 的值为123456 若此时 update titles set title='ddd' where title_id=1

再执行select title_id,binary_checksum(*)  from titles where title_id=1 会发现binary_checksum(*)的值发生了改变。

利用这个特性,我们可以先执行select title_id,binary_checksum(*) into t1 from titles 比如某段时间后需要检查或者在某个操作后需要检查有那些行发生了变化 就可以通过语句 select a.* from titles a,t1 b where a.title_id=b.title_id and a.binary_checksum(*)<>b.binary_checksum(*)

原文地址:https://www.cnblogs.com/yelisen2011/p/4125917.html