Home > Database > Mysql Tutorial > body text

如何在oracle中查询数据并同时修改状态

WBOY
Release: 2016-06-07 17:45:54
Original
1455 people have browsed it

如何在oracle中查询数据并同时修改状态

如何在oracle中查询数据并同时修改状态

这就需要能够查询一批记录并同时修改这批记录的更新状态,以免被正在更新的数据被其他服务器取到

  加行级锁,查询到记录后再遍历结果集更新状态?

  select * from t_musicinfo for update wait 10;

  这样如果某台服务器锁定记录,直到更新状态并提交这段时间,其他所有服务器都得等待,只有这台服务器释放后其他服务器才能加锁进行更新操作,10台服务器同步操作,争抢的机率岂不是很大,有没有办法使查询时对已经锁定的记录视而不见

  Google之...

  果然有:

  select * from t_musicinfo for update nowait skip locked;

  for update skip locked选项是oracle的一个未公开的特性,它的含义是select时跳过被锁的记录

  那么接下来遍历结果集更新状态

  好像不对,结果集打开后再返回,就不能再打开了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!