Skip to main content
Version: V1.0.0

SLEEP

Syntax

SLEEP(duration)

Description

The SLEEP function pauses for the specified number of seconds (duration) and returns 0 after the pause.

  • If SLEEP is executed alone and not interrupted, it returns 0.

  • If SLEEP is executed alone and interrupted, it returns 1 without any error code.

  • If SLEEP is part of a query and interrupted during the pause, it returns the error code ERROR 1317.

Examples

SELECT SLEEP(1000);
+------------------+
| SLEEP(1000) |
+------------------+
| 0 |
+------------------+

SELECT SLEEP(1000);
+------------------+
| SLEEP(1000) |
+------------------+
| 1 |
+------------------+

SELECT 1 FROM t1 WHERE SLEEP(1000);
ERROR 1317 (70100): Query execution was interrupted