如何以及何时在 MySQL 中正确使用 SLEEP()?

发布于 2024-10-04 04:00:20 字数 493 浏览 0 评论 0原文

关于我的其他问题今天我想知道如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

演多会厌 2024-10-11 04:00:20

如果您不想 SELECT SLEEP(1);,您也可以 DO SLEEP(1); 这对于程序中您不希望出现的情况很有用查看输出。

例如

SELECT ...
DO SLEEP(5);
SELECT ...

If you don't want to SELECT SLEEP(1);, you can also DO SLEEP(1); It's useful for those situations in procedures where you don't want to see output.

e.g.

SELECT ...
DO SLEEP(5);
SELECT ...
痴梦一场 2024-10-11 04:00:20
SELECT ...
SELECT SLEEP(5);
SELECT ...

但你用这个做什么?您是否试图规避/重新发明互斥体或事务?

SELECT ...
SELECT SLEEP(5);
SELECT ...

But what are you using this for? Are you trying to circumvent/reinvent mutexes or transactions?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文