DO expr [, expr] ...
DO executes the expressions but does not return any results. In most respects, DO is shorthand for SELECT , but has the advantage that it is slightly faster when you do not care about the result.expr, ...
DO执行表达式,但不返回任何结果。在大多数情况下,DO是SELECT expr的简写,…,但它的优点是,当您不关心结果时,它会稍微快一些。
DO is useful primarily with functions that have side effects, such as RELEASE_LOCK().
DO主要用于有副作用的函数,如RELEASE_LOCK()。
Example: This SELECT statement pauses, but also produces a result set:
示例:这个SELECT语句暂停,但也产生一个结果集:
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.:
另一方面,DO会暂停而不产生结果集。
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.
这可能很有用,例如在存储函数或触发器中,它们禁止生成结果集的语句。
DO only executes expressions. It cannot be used in all cases where SELECT can be used. For example, DO id FROM t1 is invalid because it references a table.
DO只执行表达式。不能在所有可以使用SELECT的情况下使用它。例如,DO id FROM t1无效,因为它引用了一个表。
MySQL的DO语句用于执行表达式,尤其适合有副作用的函数,如RELEASE_LOCK(),它在不需要结果集时比SELECT更快。在存储函数或触发器中,DO能避免产生结果集,而SELECT则可能会导致错误。
840

被折叠的 条评论
为什么被折叠?



