10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 41.5Mb
PDF (A4)- 41.6Mb
手册页(TGZ)- 262.2Kb
Man Pages (Zip)- 372.3Kb
Info (Gzip)- 4.0Mb
Info (Zip)- 4.0Mb
Excerpts from this Manual

13.2.3 DO Statement

DOexpr[,expr] ...

DOexecutes the expressions but does not return any results. In most respects,DOis shorthand forSELECTexpr, ..., but has the advantage that it is slightly faster when you do not care about the result.

DOis useful primarily with functions that have side effects, such asRELEASE_LOCK().

Example: ThisSELECTstatement pauses, but also produces a result set:

mysql> SELECT SLEEP(5); +----------+ | SLEEP(5) | +----------+ | 0 | +----------+ 1 row in set (5.02 sec)

DO, on the other hand, pauses without producing a result set.:

mysql> DO SLEEP(5); Query OK, 0 rows affected (4.99 sec)

This could be useful, for example in a stored function or trigger, which prohibit statements that produce result sets.

DOonly executes expressions. It cannot be used in all cases whereSELECT可以使用。例如,DO id FROM t1is invalid because it references a table.