如何以及何时在 MySQL 中正确使用 SLEEP()?
关于我的其他问题今天我想知道如何使用 MySQL 的 SLEEP(持续时间)
正确。
根据我阅读 MySQL 开发论坛和 MySQL 文档中非常模糊的描述所收集的信息,我不能以这种方式使用它:
SELECT ...
SLEEP(1); /* wait for a second before another SELECT */
SELECT ...
那么它有什么好处呢?
In relation to my other question today I am wondering how to use MySQL's SLEEP(duration)
correctly.
From what I gathered reading MySQL Dev forums and very vague description in MySQL Docs I can't use it this way:
SELECT ...
SLEEP(1); /* wait for a second before another SELECT */
SELECT ...
So what is it good for then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想
SELECT SLEEP(1);
,您也可以DO SLEEP(1);
这对于程序中您不希望出现的情况很有用查看输出。例如
If you don't want to
SELECT SLEEP(1);
, you can alsoDO SLEEP(1);
It's useful for those situations in procedures where you don't want to see output.e.g.
但你用这个做什么?您是否试图规避/重新发明互斥体或事务?
But what are you using this for? Are you trying to circumvent/reinvent mutexes or transactions?