Important

You are viewing the documentation of an older version of the TiDB database (TiDB v5.4).

It is recommended that you use the latest LTS version of the TiDB database.

DO

DO executes the expressions but does not return any results. In most cases, DO is equivalent to SELECT expr, ... that does not return a result.

Note

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.

In MySQL, a common use case is to execute stored procedure or trigger. Since TiDB does not provide stored procedure or trigger, this function has a limited use.

Synopsis

DoStmt
DOExpressionList
ExpressionList
Expression,
Expression
singleAtIdentifierassignmentEqNOTExpressionlogOrXORlogAndExpressionMATCH(ColumnNameList)AGAINST(BitExprFulltextSearchModifierOpt)PredicateExprIsOrNotOpNULLCompareOpsingleAtIdentifierassignmentEqPredicateExprAnyOrAllSubSelectIsOrNotOptrueKwdfalseKwdUNKNOWN

Examples

This SELECT statement pauses, but also produces a result set.

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

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

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

mysql> DO SLEEP(1), SLEEP(1.5);
Query OK, 0 rows affected (2.50 sec)

MySQL compatibility

This statement is understood to be fully compatible with MySQL. Any compatibility differences should be reported via an issue on GitHub.

See also

Was this page helpful?